HI

  • 12 years ago

    can u say to me how to bind data to gridview using asp.net

     

     

    urgent

  • 12 years ago
    Hello, its very simple take data in dataset & bind the Data grid. i'll give you code. public void BindData() { string connectionString = myDataSource.ConnectionString; SqlConnection myConnection = new SqlConnection(connectionString); SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection); DataSet ds = new DataSet(); ad.Fill(ds, "Categories"); myGridView.DataSource = ds; myGridView.DataBind(); } this function is called in Page load if(!IsPostBack) { BindData(); }

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous