Current location - Loan Platform Complete Network - Big data management - How to use c# to datagridview refresh, is not re-binding, how to re-bind.
How to use c# to datagridview refresh, is not re-binding, how to re-bind.
I have done datagridview here to achieve data binding and refresh the vb code snippet, you seriously look at (change the syntax on it), it should help, the database is the name info.mdb (also access database);

Protected Sub datagridview_ UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI. UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles d.UpdateCommand

//Database Field Name

Dim aname As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text

Dim azhuan As String = CType(e.Item.Cells(2). TextBox).Text

Dim aasp As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text

Dim ac As String = CType(e.Item.Cells(4). Controls(0), TextBox).Text

Dim ajava As String = CType(e.Item.Cells(5).Controls(0), TextBox).Text

Dim acc As String = CType(e.Item. .Cells(6).Controls(0), TextBox).Text

//Database Connection

Dim conn1 As New OleDbConnection

conn1.ConnectionString = "Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("info.mdb")

conn1.Open()

Dim cmd As New OleDbCommand

'cmd. CommandText = "update score set name='" & aname & "',major='" & azhuan & "',asp=" & aasp & ",c++=" & ac & ",java=" &. ajava & ",c#=" & acc & " where " & d.DataKeyField & "='" & d.DataKeys(e.Item.ItemIndex) & "'"

cmd.CommandText = " update score set name='" & aname & "',major='" & azhuan & "',asp=" & aasp & "',c language=" & ac & ", java=" & ajava & ", photoshop=" & acc & " where " & d.DataKeyField & "='" & d.DataKeys(e.Item.ItemIndex) & "'"

cmd.Connection = conn1

Try

cmd.ExecuteNonQuery()

conn1.Close()

d.EditItemIndex = -1

bindlist()

Catch

Response.Write (cmd.CommandText)

End Try

End Sub