DataKeyNames="accumulatorname"
getting the selected radgrid values in c#
first we need to set the properities:
<telerik:RadGrid ID="radGridPromotionStatus" runat="server" class="inputfields"
GridLines="None" AutoGenerateColumns="False" CssClass="Grid" width="800"
meta:resourcekey="radGridResource1"
CellSpacing="0" OnSelectedIndexChanged="Page_PreRender" DataKeyNames="column11" >
<ClientSettings AllowColumnsReorder="False" EnablePostBackOnRowClick="true" >
<Selecting AllowRowSelect="true" />
<%--<ClientEvents runat="server" OnRowSelected="Page_PreRender" />--%>
<Resizing AllowColumnResize="True" />
</ClientSettings>
<MasterTableView NoDetailRecordsText=" " DataKeyNames="accumulatorname" >
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="accumulatorname" HeaderText="Accumulator Name"
UniqueName="column11" meta:resourcekey="GridBoundColumnResource11" HeaderStyle-Width="125px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="accumulationamount" HeaderText="Accumulation Amount"
UniqueName="column12" meta:resourcekey="GridBoundColumnResource12" HeaderStyle-Width="125px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="nextthresholdnumber" HeaderText="NextThreshold Number"
UniqueName="column13" meta:resourcekey="GridBoundColumnResource13" HeaderStyle-Width="150px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="nextthresholdid" HeaderText="NextThreshold ID"
UniqueName="column14" meta:resourcekey="GridBoundColumnResource14" HeaderStyle-Width="125px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="reachedthresholdnumber" HeaderText="Reachedthreshold Number"
UniqueName="column15" meta:resourcekey="GridBoundColumnResource14" HeaderStyle-Width="150px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="reachedthresholdid" HeaderText="Reachedthreshold ID"
UniqueName="column16" meta:resourcekey="GridBoundColumnResource14" HeaderStyle-Width="125px" >
</telerik:GridBoundColumn>
</Columns>
<NoRecordsTemplate>
<div style="text-align: center; padding-top: 50px; height: 100px; font-size: 12pt;">
<asp:Label ID="lblNoRecords" meta:resourcekey="lblNoRecordsResource1" runat="server" Text="There are no records to display"></asp:Label>
</div>
</NoRecordsTemplate>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
<FooterStyle CssClass="GridFooter"></FooterStyle>
<HeaderStyle CssClass="GridHeader"></HeaderStyle>
<ItemStyle CssClass="GridRow"></ItemStyle>
<FilterMenu EnableImageSprites="False"></FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
</telerik:RadGrid>
in coding:
protected void Page_PreRender(object sender, EventArgs e)
{
// string selectedItemname = string.Empty;// ;
object SelectedValue=null;
if (radGridPromotionStatus.SelectedItems.Count > 0)
{
SelectedValue = radGridPromotionStatus.SelectedValue;
//var name = radGridPromotionStatus.SelectedValues["column11"].ToString();
//foreach (GridDataItem item in radGridPromotionStatus.SelectedItems)
//{
// selectedItemname = item["column11"].Text;
//}
}
if (SelectedValue != null)
{
divcontext.Visible = true;
}
//if (selectedItemname != "")
//{
// // divcontext.Visible = true;
//}
else
{
}
}