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

Grab a row value from a template column action event

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Omarr
Top achievements
Rank 1
Omarr asked on 31 Oct 2008, 05:52 PM
How do you grab the value of a row from a checkbox checked changed event? This checkbox exist under the template column.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Nov 2008, 04:47 AM
Hello Omarr,

Try out the following code to get the row index or the text in another column of the same row.
aspx:
 <telerik:GridTemplateColumn UniqueName="Template" > 
      <ItemTemplate> 
         <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox3_CheckedChanged" />          
      </ItemTemplate>         
 </telerik:GridTemplateColumn>      
 <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName"
 </telerik:GridBoundColumn> 
         

cs:
protected void CheckBox3_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox chk = (CheckBox)sender; 
        GridDataItem dataitem = (GridDataItem)chk.NamingContainer; 
        // to access the text value from the bound column 
        string strtxt = dataitem["FirstName"].Text; 
        // to get the row index 
        int index = dataitem.ItemIndex; 
    } 

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