Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RadGrid Get Selected Row Index from Item Template Button
- <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"
- DataSourceID="cusGrid" GridLines="None" Skin="Default" AllowPaging="True" DataKeyValue="CustomerID"
- PageSize="500" AllowMultiRowSelection="True" ShowStatusBar="true" >
- <MasterTableView AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="cusGrid">
- <RowIndicatorColumn>
- <HeaderStyle Width="20px"></HeaderStyle>
- </RowIndicatorColumn>
- <ExpandCollapseColumn>
- <HeaderStyle Width="20px"></HeaderStyle>
- </ExpandCollapseColumn>
- <Columns>
- <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn">
- <ItemTemplate>
- <asp:Button runat="server" Text="Select" OnClick="SelRecord" />
- </ItemTemplate>
- </telerik:GridTemplateColumn>
- ...
- protected void SelRecord(object sender, EventArgs e)
- {
- var gRow = (GridViewRow)(sender as Control).Parent.Parent;
- var key = string.Empty;
- if (gRow != null) { key = gRow.Cells[0].Text; }
- }
- protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
- {
- if (e.Item is GridDataItem)
- {
- GridDataItem dataItem = e.Item as GridDataItem;
- int selectedRowIndex = dataItem.RowIndex;
- }
- }
- <asp:Button ID="Button1" runat="server" CommandArgument='<%#Container.ItemIndex%>' OnCommand="Button1_Command" ... />
- protected void Button1_Command(object sender, CommandEventArgs e)
- {
- GridDataItem item = RadGrid1.Items[(int)e.CommandArgument];
- }
- foreach (GridDataItem item in RadGrid1.SelectedItems)
- {
- GridDataItem item = (GridDataItem)RadGrid1.SelectedItems;
- var key = string.Empty;
- key = item.ItemIndex;
- }
- var gRow = ((sender as Button).NamingContainer as GridItem).Selected;
- if (gRow != null) { key = gRow.Cells[0].Text; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement