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.
1 Answer
+ 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();
}
}