更新已检查的gridview行 [英] Update checked gridview rows

查看:81
本文介绍了更新已检查的gridview行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我只更新了GridView中已检查的行。我需要根据Checked行的ID值更新一个列单元格值



我尝试过:



我试过这段代码,但是它更新了随机行,而不是经过检查,你能帮我解决这个问题吗?

Hi All

I had a problem with updating only the checked rows in GridView. I need to update one column cell value based on the ID value of the Checked rows only

What I have tried:

I tried this code but it update random rows, not the checked, can you please help me solve this issue?

Try
    Dim I As Integer
    For I = 0 To GridView1.SelectedRowsCount() - 1
        If (GridView1.GetSelectedRows()(I) >= 0) Then
            Dim strID As String = GridView1.GetRowCellValue(I, "ID")
            Dim strUpdate As String = "UPDATE records SET payment_order= @payment_order where ID = @ID"
            cmd.CommandType = CommandType.Text
            cmd.CommandText = strUpdate.ToString()
            cmd.Parameters.Clear()
           
            cmd.Parameters.AddWithValue("@payment_order", rfnd_id_lbl.Text)
            cmd.Parameters.AddWithValue("@ID", strID)
            cmd.Connection = con
            con.Open()
            cmd.ExecuteNonQuery()
        End If
    Next

Catch ex As SqlException
    Dim errorMsg As String = "Error in Update"
    errorMsg += ex.Message
    Throw New Exception(errorMsg)
Finally
    con.Close()
End Try

推荐答案

看看这个 - 批量编辑使用CheckBoxes在ASP.Net GridView中更新多行 [ ^ ]。
Check this out - Bulk Edit Update Multiple Rows in ASP.Net GridView using CheckBoxes[^].


这篇关于更新已检查的gridview行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆