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

Rad Grid Checked status lost on page post back

3 Answers 284 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 19 Jan 2012, 09:45 PM
Hi,

I have used checkbox control inside gridtemplatecolumn of radgrid. I have used needdatasource for data binding. When i click on remove button on my page after selecting(checked) some grid row then checked status is lost after post back and no delete is performed.
Because needdatasource is called before Remove button's eventhandler.

Please suggest solution for this.

Regards,
Abhishek Dixit

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jan 2012, 04:39 AM
Hello Abhishek,

Check the following help documentation which explains how to persist check box value on page post back.
Persisting CheckBox control state in GridTemplateColumn on rebind

-Shinu.
0
Abhishek
Top achievements
Rank 1
answered on 20 Jan 2012, 07:24 AM

Hi Shinu,

Thanks for your reply. In my case i have use Check All feature also using following javascript. So can you suggest any solutution that will work with this functionality.
And also in my case posback is caused by a Button Remove outside Grid control.  Actually i wanted to implement Remove/Remove All feature in radgrid.

<script id="gridLicenseObjectMappingSelectAll" type="text/javascript">
    //To check uncheck grid check box
    $(document).ready(function () {
        var gridView1Control = document.getElementById('<%= gridLicenseObjectMapping.ClientID %>');
 
        $('input:checkbox[id$=CheckSelectAll]', gridView1Control).click(function (e) {
            if (this.checked) {
                $('input:checkbox[id$=CheckSelect]', gridView1Control).attr('checked', true);
            }
            else {
                $('input:checkbox[id$=CheckSelect]', gridView1Control).removeAttr('checked');
            }
        });
 
        $('input:checkbox[id$=CheckSelect]', gridView1Control).click(function (e) {
 
            //To uncheck the header checkbox when there are no selected checkboxes in itemtemplate
            if ($('input:checkbox[id$=CheckSelect]:checked', gridView1Control).length == 0) {
 
                $('input:checkbox[id$=CheckSelectAll]', gridView1Control).removeAttr('checked');
            }
            //To check the header checkbox when there are all selected checkboxes in itemtemplate
            else if ($('input:checkbox[id$=CheckSelect]:checked', gridView1Control).length == $('input:checkbox[id$=CheckSelect]', gridView1Control).length) {
 
                $('input:checkbox[id$=CheckSelectAll]', gridView1Control).attr('checked', true);
            }
            else {
                $('input:checkbox[id$=CheckSelectAll]').removeAttr('checked');
 
            }
        });
    });
         
</script>

0
Andrey
Telerik team
answered on 23 Jan 2012, 02:53 PM
Hi,

The approach proposed by Shinu is also applicable in your case, no matter of the client-code you are using.

Give this approach a try and check whether this is the desired behavior.

Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Abhishek
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or