This is a migrated thread and some comments may be shown as answers.

how to maintain selected?

2 Answers 100 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 21 Jan 2009, 10:19 PM
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.
thanks
mac
 
    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  
        Next  
 
 
        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">  
</telerik:RadGrid> 
<datasource> 
<asp:panel id="infoPanel" runat="server">  
table of literal ctrls  
<asp:button id="Continue" runat=server /> 
</asp:panel> 
</telerik:ajaxPanel> 
 
 
 

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Jan 2009, 06:15 AM
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

Princy.
0
Sai Krishna
Top achievements
Rank 1
answered on 18 Jan 2010, 01:08 PM
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" /> 
 </ClientSettings> 

in this case it is not working for me.

please help me out

Regards,
Sai
Tags
Ajax
Asked by
mac
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sai Krishna
Top achievements
Rank 1
Share this question
or