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

If there are no records the header checkbox is checked

1 Answer 23 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 25 Mar 2009, 05:34 PM
Hi,
I have a grid and a checkbox column in it.

it the grid is not having any records it says there are no records and the Header text box is checked by default.
i tried to make checked = false in databound and itemcreated events but it didnt work.

any ideas how to make it checked = false

Thanks
-Krishna

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 26 Mar 2009, 06:14 AM
Hello Krishna,

I could replicate the same issue at my end. But as a work around you can try out the following code:
aspx:
<telerik:RadGrid ID="RadGrid2" runat="server" AllowMultiRowSelection="true" OnNeedDataSource="RadGrid2_NeedDataSource" OnPreRender="RadGrid2_PreRender" OnItemDataBound="RadGrid2_ItemDataBound">  
    <ClientSettings >  
        <ClientEvents OnGridCreated="GridCreated" />  
        <Selecting AllowRowSelect="true" />         
    </ClientSettings>  
   <MasterTableView>  
     ....  
 
</telerik:RadGrid> 
 
<asp:HiddenField ID="HiddenField1" runat="server" /> 

c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        GridHeaderItem header = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0]; 
        string clientid = ((CheckBox)header["ClientSelectColumn"].Controls[0]).ClientID; 
        HiddenField1.Value = clientid; 
    } 

js:
<script type="text/javascript"
function GridCreated() 
   var hiddenfield = document.getElementById("HiddenField1"); 
   var control = document.getElementById(hiddenfield.value); 
   control.checked = false
 
</script> 

Thanks
Princy.
Tags
Grid
Asked by
Krishna
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or