hi,
i am using check box to select one row or multiple rows in the grid. I would
like to get the key value(Id) for multiple selected rows in an On Click
event of a button. The button is not part of the grid.
plz help me
i used this belwo code.in aspx file
<telerik:RadGrid Width="50%" ID="RadGrid1" runat="server"
AllowPaging="True" AllowSorting="True" GridLines="None"
ShowFooter="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" ShowStatusBar="True"
AutoGenerateColumns="False"
ondeletecommand="RadGrid1_DeleteCommand"
oninsertcommand="RadGrid1_InsertCommand"
onupdatecommand="RadGrid1_UpdateCommand"
AllowMultiRowSelection="True"
Skin="Web20" ondetailtabledatabind="RadGrid1_DetailTableDataBind"
onneeddatasource="RadGrid1_NeedDataSource" onselectedindexchanged="RadGrid1_SelectedIndexChanged"
>
....
......
<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
<HeaderStyle Width="30px"></HeaderStyle>
<HeaderTemplate>
<asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="Chkitem" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" runat="server"></asp:CheckBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
....
......
<tellerik:radGrid>
</telerik:RadGrid>
<asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click" />
in the button click event, i have to get the selected rows values.
i can get the count using radGrid1.SelectedItems.
plz guide me how to get the id value for selected rows
Thanks,
Dhana
plz help me
i used this belwo code.in aspx file
<telerik:RadGrid Width="50%" ID="RadGrid1" runat="server"
AllowPaging="True" AllowSorting="True" GridLines="None"
ShowFooter="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" ShowStatusBar="True"
AutoGenerateColumns="False"
ondeletecommand="RadGrid1_DeleteCommand"
oninsertcommand="RadGrid1_InsertCommand"
onupdatecommand="RadGrid1_UpdateCommand"
AllowMultiRowSelection="True"
Skin="Web20" ondetailtabledatabind="RadGrid1_DetailTableDataBind"
onneeddatasource="RadGrid1_NeedDataSource" onselectedindexchanged="RadGrid1_SelectedIndexChanged"
>
....
......
<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
<HeaderStyle Width="30px"></HeaderStyle>
<HeaderTemplate>
<asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="Chkitem" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" runat="server"></asp:CheckBox>
</ItemTemplate>
</telerik:GridTemplateColumn>
....
......
<tellerik:radGrid>
</telerik:RadGrid>
<asp:Button ID="Button1" runat="server" Text="Get" onclick="Button1_Click" />
in the button click event, i have to get the selected rows values.
i can get the count using radGrid1.SelectedItems.
plz guide me how to get the id value for selected rows
Thanks,
Dhana
hii
How to select row in telerik RadGrid and get value of row .
Thanks
Amit
foreach (GridDataItem item in RadGrid.SelectedItems)
{
some variable here = item["XXXXX"].Text;
}
just substitute the column name you want the value of in place of the XXXX above.
Hope that helps
i have used this code but some times an error occur how can solved it. it's shown here "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index".
and have u an idea for this problem solve . than please tell me..
Thanks
Amit