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

How to keep the previous selection of the check box after performing search on preferred column in a RadGrid

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Soumen
Top achievements
Rank 1
Veteran
Soumen asked on 15 Jun 2020, 07:39 AM

Hello,

I am new in telerik radgrid, working in c#. I am working in a radgrid which have AllowFilteringByColumn feature. I am binding this grid from code behind every time. This grid have 2 extra CheckBox column. Problem is when I am performing any search page load is called and  the checked check box disappears after page load. How can I Resolve this problem. I need to keep the previous selection of the check box after performing search on preferred column.

 

<telerik:RadGrid ID="grdAgreement" runat="server" SelectedItemStyle-CssClass="SelectedStyle"
                                    HeaderStyle-Height="40px" HeaderStyle-BackColor="#CEECF5" AutoGenerateColumns="False"
                                    GroupPanelPosition="Top" ResolvedRenderMode="Classic" Skin="Simple" Width="100%"
                                    ShowStatusBar="True" AllowMultiRowSelection="True" AllowFilteringByColumn="true"
                                    HeaderStyle-Font-Size="18px" HeaderStyle-Font-Bold="true" HeaderStyle-Font-Names="Arial Regular">
                                    <MasterTableView DataKeyNames="Id" >
                                        <Columns>                                            
                                            <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" FilterControlAltText="Filter Id column"
                                                HeaderText="ID" ReadOnly="True" SortExpression="Id" UniqueName="Id" Visible="true" AllowFiltering="false">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="DocumentTitle" FilterControlAltText="Filter DocumentTitle column"
                                                HeaderText="Document Title" SortExpression="DocumentTitle" UniqueName="DocumentTitle" AllowFiltering="true"
                                                AndCurrentFilterFunction="Contains" AutoPostBackOnFilter="True" AllowSorting="True"
                                                HeaderStyle-Font-Size="18px" FilterControlWidth="120px">
                                                <HeaderStyle Width="200px" HorizontalAlign="Center" />
                                            </telerik:GridBoundColumn>                                           
                                            <telerik:GridTemplateColumn HeaderText="Select for Template" AllowFiltering="false">
                                                 <ItemTemplate>
                                                          <asp:CheckBox ID="chkSelectForTemplate" Checked='<%# Eval("SelectforTemp") %>' runat="server" />
                                                 </ItemTemplate>
                                            </telerik:GridTemplateColumn> 
                                        </Columns>
                                    </MasterTableView>
                                    <HeaderStyle BackColor="#CEECF5" Height="40px"></HeaderStyle>
                                    <SelectedItemStyle CssClass="SelectedStyle"></SelectedItemStyle>
                                </telerik:RadGrid>

 

code behind

if (!IsPostBack)
        {
            if (Request.QueryString["ID"] != null)
            {
                string str_id = Request.QueryString["ID"].ToString();
                if (str_id != "")
                {
                    // code for select by ID
                    BindingGrid(str_id);
                }
            }
            else
            {
                BindingGrid();
            }           
        }
        else
        {            
        }

1 Answer, 1 is accepted

Sort by
0
Accepted
Attila Antal
Telerik team
answered on 17 Jun 2020, 01:50 PM

Hi Soumen,

RadGrid is an extended version of the ASP GridView and it has its own binding technique. That is the Programmatic Data Binding Using the NeedDataSource Event.

I recommend changing the binding technique for the Grid and test the application again. Once you bind the Grid using this technique, make sure the DataBind() method is not called anywhere in the code behind, see How to bind RadGrid properly on server-side

Kind regards,
Attila Antal
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Soumen
Top achievements
Rank 1
Veteran
Answers by
Attila Antal
Telerik team
Share this question
or