how to maintain selected?

3 posts, 1 answers
  1. mac
    mac avatar
    137 posts
    Member since:
    May 2008

    Posted 21 Jan 2009 Link to this post

    hi stuck on something with radgrid and ajax panel
    I have a radgrid with 20 columns(15 hidden), one datasource, one textbox, two buttons(search and continue), one table with lierals for the 15 hidden columns outside the grid.
    Scenario: Radgrid and table are wrapped in an ajaxpanel. User enters search criteria in textbox 1, radgrid populates based on criteria. User uses COmmandName 'Select' to select row. SelectedIndexChanged grabs values of selected row and populates literals. Very nice. User presses continue and goes to next page. if user uses back button, all data is then missing! This is definitely due to my use of the ajaxpanel. is there a way to keep the page in its selected state and use the ajax?
    My designer data is simplified significantly but the idea is there.
        Protected Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged  
            For Each item As GridDataItem In RadGrid1.MasterTableView.GetItems(New GridItemType() {GridItemType.Item, GridItemType.AlternatingItem})  
                Dim dataitem As GridDataItem = DirectCast(item, GridDataItem)  
                If dataitem.Selected Then  
                    'Access the data in the row using the ColumnUniqueName      
                    EMP_IDlit.Text = dataitem("EMP_ID").Text  
                    EMPFirstNamelit.Text = dataitem("EMPFirstName").Text  
                    EMPLastNamelit.Text = dataitem("EMPLastName").Text  
                    EMPPoslit.Text = dataitem("EMPPos").Text  
                    PosDescriptionlit.Text = dataitem("PosDescription").Text  
                    PosTypelit.Text = dataitem("PosType").Text  
                    HomePoslit.Text = dataitem("HomePos").Text  
                    Emp_Statuslit.Text = dataitem("Emp_Status").Text  
                    Classnlit.Text = dataitem("Classn").Text  
                    CostCentrelit.Text = dataitem("CostCentre").Text  
                    site_prelit.Text = dataitem("site_pre").Text  
                    sitelit.Text = dataitem("site").Text  
                    Affiliationlit.Text = dataitem("Affiliation").Text  
                    std_hourslit.Text = dataitem("std_hours").Text  
                    Documentlit.Text = dataitem("Document").Text  
                    Departmentlit.Text = dataitem("Department").Text  
                    homesitelit.text = dataitem("homesite").Text  
                    infopanel.visible = True 
                End If  
            EmpPos = RadGrid1.SelectedValues("EmpPos")  
            Empid = RadGrid1.SelectedValues("Emp_ID")  
            SelectedID.Text = EmpPos & "|" & Empid & "|" & JDC  
        End Sub 

    Design is along these lines

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" 
            runat="server" Text="Name or Pos#" /> 
        <telerik:RadAjaxPanel ID="pnl" runat="server">  
        <telerik:RadGrid ID="RadGrid1"     runat="server" AutoGenerateColumns="False">  
    <asp:panel id="infoPanel" runat="server">  
    table of literal ctrls  
    <asp:button id="Continue" runat=server /> 
  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Jan 2009 Link to this post

    Hello Mac,

    RadGrid tends to lose its selection when the current page changes and it can happen even if you use Ajax settings. Inorder to persist the selection of items across pages in a grid, you can store the key values for the selected rows in a Session variable or ViewState. Then in the pre-render event of the grid, you can loop through the rows of the grid and compare their key values to the values saved in the session variable and set the matched rows as selected. Refer to the following help document to find out how to implement this scenario.
    Persisting the selected rows server-side on sorting/paging/filtering/grouping

  3. Sai Krishna
    Sai Krishna avatar
    8 posts
    Member since:
    Nov 2009

    Posted 18 Jan 2010 Link to this post

    Hi Princy,

    Thanks for sharing the article, it was nice.
    however in my case i am using client to select the row,
     <ClientSettings EnablePostBackOnRowClick="True">  
                            <Selecting AllowRowSelect="true" /> 

    in this case it is not working for me.

    please help me out

Back to Top