bind datatable rows to each gridview row from database

Last Reply 10 days ago By dharmendr

Posted 12 days ago

how to bind datatable rows to each gridview row from database..below is the code sample...

            for (int i = 0; i < GridView1.Rows.Count; i++)

                GridView1.Rows[i].Cells[0].Text = dt.Rows[0]["Id"].ToString();
                GridView1.Rows[i].Cells[1].Text = dt.Rows[0][1].ToString();
                GridView1.Rows[i].Cells[2].Text = dt.Rows[0][2].ToString();
             //  GridView1.DataSource = dt;

where is the correction needed??

thanks in advance

You are viewing reply posted by: Andrea 12 days ago.
Posted 12 days ago
Hi @jochk12345,
Please try the following

Bind GridView from Database and add new row on Button Click using C# and VB.Net in ASP.Net

It might help you.

Cheers Andrea.