Hi
I have a Radiobutton next to every row of RadGrid.
I am trying to access the datakeyvalue of a selected row using radiobutton, i.e., when particular row's Radiobutton of RadGrid is checked, then on 'CheckedChanged' event of RadioButton, I am trying to get the datakey value of that row inside a label or variable.
aspx page Code:
.cs page code:
but unable to get the DataKeyValue of selected row.
I also want to call the selected row's DataKeyValue on another page(say Default.aspx), to show the particuar RadGrid row's record on other page(say Default.aspx)
Please help me what is missing in my code?
I have a Radiobutton next to every row of RadGrid.
I am trying to access the datakeyvalue of a selected row using radiobutton, i.e., when particular row's Radiobutton of RadGrid is checked, then on 'CheckedChanged' event of RadioButton, I am trying to get the datakey value of that row inside a label or variable.
aspx page Code:
<
telerik:RadGrid
ID
=
"RadGrid1"
EnableViewState
=
"false"
runat
=
"server"
AllowPaging
=
"true"
AllowSorting
=
"False"
AllowFilteringByColumn
=
"true"
GridLines
=
"None"
OnInit
=
"RadGrid1_Init"
OnDeleteCommand
=
"RadGrid1_DeleteCommand"
>
<
ItemStyle
Wrap
=
"false"
></
ItemStyle
>
<
MasterTableView
AllowMultiColumnSorting
=
"true"
TableLayout
=
"Fixed"
DataKeyNames
=
"Id"
ClientDataKeyNames
=
"Id"
>
<
Columns
>
<
telerik:GridNumericColumn
DataField
=
"Id"
HeaderText
=
"Id"
HeaderStyle-Width
=
"100px"
AllowFiltering
=
"False"
FilterControlWidth
=
"50px"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
HeaderText
=
"Description"
AndCurrentFilterFunction
=
"Contains"
FilterListOptions
=
"AllowAllFilters"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
""
HeaderText
=
"Select"
>
<
ItemTemplate
>
<
asp:RadioButton
ID
=
"rbdSelect"
runat
=
"server"
AutoPostBack
=
"true"
OnCheckedChanged
=
"rbdSelect_CheckedChanged"
></
asp:RadioButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
protected void rbdSelect_CheckedChanged(object sender, EventArgs e)
{
foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
{
RadioButton rbd = (RadioButton)item.FindControl("rbdSelect");
if (rbd.Checked==true)
{
string key = item.GetDataKeyValue("Id").ToString();
//string id = RadGrid1.MasterTableView.Items[0].GetDataKeyValue("Id").ToString();
}
}
Response.Redirect("~/PrintInvoice.aspx");
}
I also want to call the selected row's DataKeyValue on another page(say Default.aspx), to show the particuar RadGrid row's record on other page(say Default.aspx)
Please help me what is missing in my code?