Hi, i am trying to make a fully editable dataGrid and was using the
"Top Ten Questions about the DataGrid Control" article in the MSDN
Library as a guide. The following is my current vb code. I ran the
page, and only the first row updates. Can anyone help with this
problem? Thanks, TS
Public Sub dgUpdate(ByVal s As Object, ByVal e As EventArgs)
Dim i As Integer
Dim dgi As DataGridItem
Dim lblSID As Label
Dim txtC1 As TextBox
Dim txtC2 As TextBox
Dim txtC3 As TextBox
Dim txtC4 As TextBox
Dim txtE1 As TextBox
Dim txtS1 As TextBox
Dim intSID As String 'StudentID
Dim cmdUp As OleDbCommand
Dim strUp
strUp = "Update StudentData Set C1=@C1, C2=@C2, C3=@C3, C4=@C4,
E1=@E1, S1=@S1 Where StudentID=@SID and TchID=@TchID And
CourseID=@CourseID"
cmdUp = New OleDbCommand(strUp, conPI)
Dim totCount As Integer
totCount = dgrdStudents.Items.Count
For i = 0 To totCount - 1
dgi = dgrdStudents.Items(i)
lblSID = CType(dgi.FindControl("lblSID"*), Label)
intSID = CType(lblSID.Text, String)
txtC1 = CType(dgi.FindControl("txtC1")*, TextBox)
txtC2 = CType(dgi.FindControl("txtC2")*, TextBox)
txtC3 = CType(dgi.FindControl("txtC3")*, TextBox)
txtC4 = CType(dgi.FindControl("txtC4")*, TextBox)
txtE1 = CType(dgi.FindControl("txtE1")*, TextBox)
txtS1 = CType(dgi.FindControl("txtS1")*, TextBox)
cmdUp.Parameters.Add("@C1", txtC1.Text)
cmdUp.Parameters.Add("@C2", txtC2.Text)
cmdUp.Parameters.Add("@C3", txtC3.Text)
cmdUp.Parameters.Add("@C4", txtC4.Text)
cmdUp.Parameters.Add("@E1", txtE1.Text)
cmdUp.Parameters.Add("@S1", txtS1.Text)
cmdUp.Parameters.Add("@SID", lblSID.Text)
cmdUp.Parameters.Add("@TchID", varTID)
cmdUp.Parameters.Add("@CourseI*D",
Request.QueryString("CourseID"*))
conPI.Open()
cmdUp.ExecuteNonQuery()
conPI.Close()
Next
BindDataGrid()
End Sub