-3

There is a hierarchy (parent-child) relationship between three Tables A > B > C in Database ..

I need to load some fields from each table into GridView and change data then save it back into the Database by ASP.NET with C# with ADO.NET
But I need a little sample code, I searched but couldn't find any thing for this scenario ..

Any help, thanks.

4

2 回答 2

0

下面是一个很好的链接。
这个想法很简单,用户gridview events还是data-source要显示和更新数据库。

http://www.aspdotnetcodes.com/SQLDataSource_StoredProcedure_Multiple_Tables_Update.aspx

有很多事情gridview需要你去探索。
http://asp-net-example.blogspot.in/search/label/GridView%20Example

于 2013-04-06T04:49:32.263 回答
0

您可以遍历整个 GridView,并从每一行获取数据。然后将这些数据(每一行)逐行插入到测试表中:

foreach (GridViewRow gvr in GridView1.Rows)
{
    string data1 = gvr.Cells[0].Text;    
      //get data from BoundField in each row
    string data2 = ((Label)gvr.FindControl("Label1")).Text;    
      //get data from control in TemplateField in each row
    SqlCommand cmd = new SqlCommand("insert_sql", conn);   
      //generate insert sql using above data
    cmd.ExecuteNonQuery();
}
于 2013-04-06T03:36:55.953 回答