SqlConnection scon = new SqlConnection("database=StudentDB;trusted_connection=yes");
SqlCommand scmd = new SqlCommand("select* from StudentInfoTable", scon);
SqlDataAdapter sda = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
// And finally giving the object of DataSet to the Gridview having ID="Gridview1" last two line to bind the Dataset to the Gridview.
No comments:
Post a Comment