D
DavidC
How can I get the RowIndex of a GridView when clicking on a checkbox in
read-only mode? I have done it with the code below in a ListView but I
cannot figure out how to do the same in a GridView. Thanks.
Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs)
' Gets the CheckBox object that fired the event.
Dim chkBox As CheckBox = CType(sender, CheckBox)
' Gets the item that contains the CheckBox object.
Dim item As ListViewDataItem = CType(chkBox.Parent, ListViewDataItem)
Dim intTransID As Int32 =
Convert.ToInt32(lvIncExpTrans.DataKeys(item.DataItemIndex).Value)
If VendorClass.ChangeIncExpTransPick(intTransID, chkBox.Checked) =
False Then
Dim tb As TextBox = Page.Master.FindControl("txtMsg")
' Replace ListView1 with ID of your ListView Control
'tb.Text = "TransID sent = " &
lvIncExpTrans.DataKeys(item.DataItemIndex).Value
tb.Text = "The update to the checkbox failed."
End If
lvIncExpTrans.DataBind()
End Sub
read-only mode? I have done it with the code below in a ListView but I
cannot figure out how to do the same in a GridView. Thanks.
Sub Check_Clicked(ByVal sender As Object, ByVal e As EventArgs)
' Gets the CheckBox object that fired the event.
Dim chkBox As CheckBox = CType(sender, CheckBox)
' Gets the item that contains the CheckBox object.
Dim item As ListViewDataItem = CType(chkBox.Parent, ListViewDataItem)
Dim intTransID As Int32 =
Convert.ToInt32(lvIncExpTrans.DataKeys(item.DataItemIndex).Value)
If VendorClass.ChangeIncExpTransPick(intTransID, chkBox.Checked) =
False Then
Dim tb As TextBox = Page.Master.FindControl("txtMsg")
' Replace ListView1 with ID of your ListView Control
'tb.Text = "TransID sent = " &
lvIncExpTrans.DataKeys(item.DataItemIndex).Value
tb.Text = "The update to the checkbox failed."
End If
lvIncExpTrans.DataBind()
End Sub