What is Data Source Control with example?

 Posted by Tripati_tutu on 1/10/2011 | Category: ASP.NET Interview questions | Views: 5158 | Points: 40
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 

Comments or Responses

Login to post response