Answer: With the help of Data Source Control, we can perform the data binding operation by writing some data access code. This is used to retrive a DataReader or a DataSet object from the server and you can show that retrived data in DataGrid, DropDownLIst or in ListBox.
Example:
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand("Select * from Emp", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
Asked In: Many Interviews |
Alert Moderator