【问题标题】:how to use gridview values to update another table in database using asp.net c#如何使用gridview值使用asp.net c#更新数据库中的另一个表
【发布时间】:2023-03-27 15:54:01
【问题描述】:

我有一个GridView,它绑定到 SQLdatasource。我编辑它,数据库中的相应表得到更新。 一旦我完成编辑GridView 中的所有行,在 button_click 上我想读取 GridView 中的每一行,其中有条目并使用我的 GridView 中的第一列 Location 在哪里子句并更新数据库中的另一个不同的表。

请帮助。提前谢谢你。

【问题讨论】:

    标签: c# asp.net sql gridview


    【解决方案1】:

    您只需要获取 Grid View 中每一行的 Column 值并使用 Update Query 通过创建另一个数据源到相应的 SQL 表来更新它。 以下代码将帮助您更好地理解。

    int rowscount = gv.Rows.Count;
    
    for (int i = 0; i < rowscount; i++)
    {
               //Iterating the Grid View
    
    
    
            RequiredColvalue = gv.Rows[i][0].Tostring();
    
       //Update Statement According to your need.
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-13
      • 1970-01-01
      • 1970-01-01
      • 2011-02-27
      • 2017-04-02
      • 1970-01-01
      • 2012-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多