更新visual studio 14中所选gridview行的列?

时间:2016-02-25 07:03:09

标签: asp.net vb.net gridview

按钮代码

Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    Mysqlconnection = New SqlConnection
    Mysqlconnection.ConnectionString = "Server=CTJY\SQLSERVER;Database=WinningAcademyDB;Integrated Security=true;"

    Dim reader As SqlDataReader

    Mysqlconnection.Open()
    Dim query As String
    query = "update Grade set Girdview4_col3 = '" & DropDownList2.SelectedValue & "' "

    command = New SqlCommand(query, Mysqlconnection)
    reader = command.ExecuteReader
End Sub

每次单击该按钮时,“成绩”列中的所有内容都会更改,并且完全相同。我只希望更改所选项目的成绩。不是全部。

1 个答案:

答案 0 :(得分:0)

你可以使用 where 来选择那些网格..也就是说,在datagrid中创建一个关于单元格选择的事件的函数,并为 where子句填充一个字符串> sql 声明..