C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







insert after that display in gridview rasie error please(The IListSource does not contain


Posted Date: 05 Jul 2008      Total Responses: 1

Posted By: Naresh       Member Level: Silver     Points: 1


public void insert(string uname,string pwd,string addr)
{

SqlConnection con = DL.GetConnection();
SqlCommand cmd = new SqlCommand("insert into rambabu (uname,pwd,addr,ltype) values('" + uname + "','" + pwd + "','" + addr + "',' + doctor + ')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();

}
public DataSet getdata(string query)
{
SqlConnection con = DL.GetConnection();
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
return ds;
}

PL:bl obj=new bl();
protected void Button1_Click(object sender, EventArgs e)
{
obj.insert(txtuname.Text, txtpwd.Text, txtaddr1.Text);
Response.Write("inserted sucussfully");

GridView1.DataSource = obj.getdata("select * from emp");
GridView1.DataBind();// rasie error The IListSource does not contain any data sources.

}
protected void Button2_Click(object sender, EventArgs e)
{
txtuname.Text = "";
txtpwd.Text = "";
txtaddr1.Text = "";
Response.Write("clear the fields");
}






Responses

Author: Mohammed Khaja Najmuddin    06 Jul 2008Member Level: GoldRating:     Points: 4
Datagrid accepts table,list of elements as datasource.u function returns dataset not table.

public Datatable getdata(string query)
{
SqlConnection con = DL.GetConnection();
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
return ds.tables[0];
}

hope u got an idea



Post Reply
You must Sign In to post a response.
Next : picking selecteddate by using telerik:RadDatePicker
Previous : Session Timeout Redirect
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use