Hello,
I have an Edit button located on my MasterPage and a RadGrid located in my Default.aspx page. I am trying to get the Session ID of the row selected in the Default.aspx page and pull in those values into my Edit page.
When I select a row in Default.aspx and then click Edit, the page refreshes and the row is deselected.
What am I doing wrong here?
Here is my code behind for the MasterPage Edit button:
The code for the RadGrid in Default.aspx is
Thanks!!!
I have an Edit button located on my MasterPage and a RadGrid located in my Default.aspx page. I am trying to get the Session ID of the row selected in the Default.aspx page and pull in those values into my Edit page.
When I select a row in Default.aspx and then click Edit, the page refreshes and the row is deselected.
What am I doing wrong here?
Here is my code behind for the MasterPage Edit button:
protected void lEditItem_Click(object sender, EventArgs e){ GetSelected(); if (Session["CriteriaID"] != null) { Session["AccessMode"] = ""; Response.Redirect("~/EditCriteria.aspx"); }}private void GetSelected(){ RadGrid control = (RadGrid)PageContent.FindControl("criteriaList"); foreach (GridDataItem item in control.MasterTableView.Items) { if (item.Selected) { String temp = item.GetDataKeyValue("ID").ToString(); Session["CriteriaID"] = new Guid(item.GetDataKeyValue("ID").ToString()); } }}The code for the RadGrid in Default.aspx is
<asp:Content ID="Content2" ContentPlaceHolderID="PageContent" runat="server"> <div class="PageBlock"> <div class="SecHeader">Criteria List</div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CriteriaCS %>" SelectCommand="SELECT [AssetOwner], [CriteriaName], [CriteriaDescription], [CriteriaType], [ID] FROM [Study]"> </asp:SqlDataSource> <telerik:RadGrid ID="criteriaList" runat="server" CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None" AllowSorting="True" AutoGenerateColumns="False"> <ClientSettings EnablePostBackOnRowClick="True"> <Selecting AllowRowSelect="True" /> <ClientEvents OnRowSelected="RowSelected"></ClientEvents> </ClientSettings> <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="ID"> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column" Created="True"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="AssetOwner" FilterControlAltText="Filter AssetOwner column" HeaderText="AssetOwner" SortExpression="AssetOwner" UniqueName="AssetOwner"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CriteriaName" FilterControlAltText="Filter CriteriaName column" HeaderText="CriteriaName" SortExpression="CriteriaName" UniqueName="CriteriaName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CriteriaDescription" FilterControlAltText="Filter CriteriaDescription column" HeaderText="CriteriaDescription" SortExpression="CriteriaDescription" UniqueName="CriteriaDescription"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CriteriaType" FilterControlAltText="Filter CriteriaType column" HeaderText="CriteriaType" SortExpression="CriteriaType" UniqueName="CriteriaType"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ID" DataType="System.Guid" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID" Visible="False"> </telerik:GridBoundColumn> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> </MasterTableView> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> </div></asp:Content>Thanks!!!