I am using the following code to be executed when a checkbox is ticked within my gridview control.
I need to be able to get the value of another cell in the same gridview row as the checkbox that was checked. How can I go about getting this value?
Basically the scenario is this:
There can be multiple checkboxes selected at any time - these are populated at page load. A user clicks another checkbox (the above function executes) and I want to execute code to update the database. To do this I need to get the value of an IMAGE_ID field which is in the same row of the Gridview that the checkbox was in. I cannot use a for each statement as I am only dealing with this given row. Any ideas how I can get cell(1).Text for this row only?
Thanks
Code:
Protected Sub cbPreviouslyViewedCheckbox_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvImages.SelectedIndexChanged
' Get the Checkbox on the selected row.
Dim checkbox As CheckBox = DirectCast(sender, CheckBox)
' Get the Surname for the selected row
Dim Image_ID As Integer = WHAT GOES HERE
lblMessage.Text = Image_ID.....
I need to be able to get the value of another cell in the same gridview row as the checkbox that was checked. How can I go about getting this value?
Basically the scenario is this:
There can be multiple checkboxes selected at any time - these are populated at page load. A user clicks another checkbox (the above function executes) and I want to execute code to update the database. To do this I need to get the value of an IMAGE_ID field which is in the same row of the Gridview that the checkbox was in. I cannot use a for each statement as I am only dealing with this given row. Any ideas how I can get cell(1).Text for this row only?
Thanks
Last edited: