0

Fill a GridView with a Query

How can I do to fill a GridView with a Query? I'm using C# in Visual Studio.

2nd Feb 2017, 3:26 PM
Christian Daniel Alvarez Pantoja
Christian Daniel Alvarez Pantoja - avatar
1 Respuesta
+ 1
protected void GridviewBind () { using (SqlConnection con = new SqlConnection("Data source=" ..........")) { con.Open(); SqlCommand cmd = new SqlCommand("Select ### FROM ### ", con); SqlDataReader dr = cmd.ExecuteReader(); GridView1.DataSource = dr; GridView1.DataBind(); con.Close(); } }
2nd Apr 2017, 5:36 PM
Ramzi Bouchair
Ramzi Bouchair - avatar