Change Live Values on Datagrid with PostBack

1 Textbox with onchange=TextboxChange and ID=TxtBox

Sub TextboxChange(ByVal sender As Object, ByVal e As System.EventArgs)Dim ck1 As TextBox = CType(sender, TextBox)
Dim dgItem As DataGridItem = CType(ck1.NamingContainer, DataGridItem)‘now we’ve got what we need!

msg.Text +=

“You selected row “ & dgItem.Cells(0).Text
‘ Convert the sender object to check box control
Dim chk As TextBox = CType(sender, TextBox)



‘ Get the parent Item of the checkbox control
Dim objItem As DataGridItem = CType(chk.Parent.Parent, DataGridItem)
msg.Text +=
“<BR>ID:” & SeasonGrid.DataKeys(CInt(objItem.ItemIndex))
msg.Text +=
“<BR>GETVALUE:” & CType(chk.FindControl(“TxtBox”), TextBox).TextIf Len(CType(chk.FindControl(“TxtBox”), TextBox).Text) > 0 Then

strsql =


“UPDATE TMPDATES SET DALLOT=” & CType(chk.FindControl(“TxtBox”), TextBox).Text & ” where TD=” & DATAGRID.DataKeys(CInt(objItem.ItemIndex))End If




Dim objCommand As New SqlCommand(strsql, Conn)If Conn.State = ConnectionState.Closed Then Conn.Open() 







Catch ex As Exception ex.Message & ” SQL “ & strsqlEnd Try



CType(chk.FindControl(“SALLOT”), TextBox).Focus()End Sub