if (!IsPostBack) { BindData(); } ......... ......... void BindData() { SqlCommand cmd1 = new SqlCommand("select * from cntus",con); SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet(); da.Fill(ds, "cntus"); //cntus is my table name GridView1.DataSource = ds.Tables["cntus"]; GridView1.DataBind(); //gridview1 is my gridview id }
da.Fill(ds,"cntus")
The SelectCommand property has not been initialized before calling 'Fill'
object
SqlDataAdapter
SqlCommand cmd1 = new SqlCommand("select * from cntus", con); SqlDataAdapter da = new SqlDataAdapter(cmd1); DataSet ds = new DataSet();
da.SelectCommand=cmd1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)