| View previous topic :: View next topic |
| Author |
Message |
pavani
Joined: 26 Mar 2010 Posts: 37
|
Posted: Wed Mar 31, 2010 5:39 am Post subject: How to Bind Data to the Grid View Data Control. |
|
|
Hi..,
I want to Bind Data to the Grid View Data control through C# Programming code. Can Any One Please help me.
Thanks In Advance. _________________ Pavani.... |
|
| Back to top |
|
 |
rajesh
Joined: 26 Mar 2010 Posts: 43
|
Posted: Wed Mar 31, 2010 5:57 am Post subject: |
|
|
Hi Pavani..,
Here I am providing you some code to bind the data in the Grid View.
SqlConnection conn = new SqlConnection("Data Source="Your-DataSource"; Initial Catalog="DataBaseName";User Id=""; Password="");
SqlDataAdapter sqlDA = new SqlDataAdapter("Select * from TableName", conn);
DataSet ds = new DataSet();
sqlDA.Fill(ds, "Users");
//to bind the data in gridview.
GridView1.DataSource = ds.Tables["Users"].DefaultView;
GridView1.DataBind();
conn.Close();
Follow the above code. _________________
***************
Best Regards
Rajesh Mani.
Nyros Technologies. |
|
| Back to top |
|
 |
|