This is a migrated thread and some comments may be shown as answers.

How can I access radgrid id on checkbox_checked event - vb.net

1 Answer 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lily
Top achievements
Rank 1
Lily asked on 05 Feb 2014, 08:09 PM
I have a radgrid. inside the radgrid I have checkBox.

If I check or uncheck any checkbox in the grid  it it rasises checkbox checked event. I want to find out the row Id of that particular checkbox that is checked.How can I do that in vb.net?? 

I dont want to loop through all the items in the grid and find out what is checked, I just want the one that is checked or unchecked at that time.

Thank you.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Feb 2014, 03:37 AM
Hi Lily,

Please try the following code snippet to have the checked row values :

ASPX:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

VB:
Protected Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
  Dim check As CheckBox = DirectCast(sender, CheckBox)
  Dim item As GridDataItem = DirectCast(check.NamingContainer, GridDataItem)
  ' Get DataKeyValue
  Dim ID As String = item.GetDataKeyValue("ID").ToString()
  ' Get BoundColumn value
  Dim city As String = item("City").Text    
End Sub

Thanks,
Princy
Tags
Grid
Asked by
Lily
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or