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

I am unable to disable a checkbox from the server

1 Answer 12 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan Harvey
Top achievements
Rank 2
Dan Harvey asked on 29 Mar 2012, 11:52 PM
Hello,

I have an ajaxified rad grid with a column that holds a delete button.  When the button is clicked, i rebind the grid to the datasource and then I disable some checkboxes.

When this happens, these checkboxes are not disabled.

Here is my grid:
<telerik:RadGrid ID="dgLoginRequest" 
                                                                 runat="server" 
                                                                 AllowSorting="True"
                                                                 AllowPaging="True" 
                                                                 AllowAutomaticUpdates="True"
                                                                 Skin="WebBlue" 
                                                                 EnableAJAX="true"
                                                                 EnableOutsideScripts="true" 
                                                                 GridLines="None"
                                                                 GroupingSettings-GroupContinuesFormatString="" 
                                                                 OnPageIndexChanged="dgLoginRequest_PageIndexChanged"
                                                                 OnItemDataBound="dgLoginRequest_ItemDataBound" 
                                                                 OnNeedDataSource="dgLoginRequest_NeedDataSource">
                                                      
                                                    <ClientSettings>
                                                        <Selecting CellSelectionMode="None" AllowRowSelect="False" />
                                                    </ClientSettings>
  
                                                    <MasterTableView AllowAutomaticDeletes="True"
                                                                     AllowAutomaticUpdates="True" 
                                                                     AutoGenerateColumns="False"
                                                                     CommandItemDisplay="None"
                                                                     DataKeyNames="EntityID" 
                                                                     Width="100%">
                                                          
                                                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                    <RowIndicatorColumn>
                                                        <HeaderStyle Width="20px" />
                                                    </RowIndicatorColumn>
                                                    <ExpandCollapseColumn>
                                                        <HeaderStyle Width="20px" />
                                                    </ExpandCollapseColumn>
                                                      
                                                        <Columns>
                                                          
                                                            <telerik:GridBoundColumn DataField="EntityID" HeaderStyle-HorizontalAlign="Center" HeaderText="Entity ID" ItemStyle-HorizontalAlign="Left" SortExpression="EntityID" Visible="False" UniqueName="EntityID">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Left" />
                                                            </telerik:GridBoundColumn>
  
                                                            <telerik:GridBoundColumn DataField="EntityName" HeaderText="Entity Name" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" SortExpression="EntityName" UniqueName="EntityName">
                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                <ItemStyle HorizontalAlign="Left" />
                                                            </telerik:GridBoundColumn>
                                                                                                                          
                                                            <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center">
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox id="headerReaderChkbox" runat="server" Text="Reader"></asp:CheckBox>
                                                                </HeaderTemplate>
  
                                                                <ItemTemplate>
                                                                    <asp:CheckBox ID="chbxReader" runat="server" Checked='<%# Eval("IsReader") %>' />
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                            <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center">
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox id="headerDropboxChkbox" runat="server" Text="RK Dropbox"></asp:CheckBox>
                                                                </HeaderTemplate>
  
                                                                <itemtemplate>
                                                                    <asp:CheckBox ID="chbxRKDropbox" runat="server" Checked='<%# Eval("IsRKDropbox") %>' />
                                                                </itemtemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                            <telerik:GridTemplateColumn HeaderText=" ">
                                                                <ItemTemplate>
                                                                    <asp:ImageButton ID="btnDelete" 
                                                                                     runat="server" 
                                                                                     CausesValidation="False"
                                                                                     ImageUrl="../Login/Images/Delete.gif"  
                                                                                     ToolTip="Delete Record" 
                                                                                     OnClick="btnDelete_Click"/>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
  
                                                        </Columns>
                                                          
                                                        <GroupByExpressions>
                                                            <telerik:GridGroupByExpression>
                                                                <GroupByFields>
                                                                    <telerik:GridGroupByField FieldName="FamilyName" />
                                                                </GroupByFields>
                                                                <SelectFields>
                                                                    <telerik:GridGroupByField FieldName="FamilyName" FieldAlias="FamilyName" HeaderText="FamilyName" />
                                                                </SelectFields>
                                                            </telerik:GridGroupByExpression>
                                                        </GroupByExpressions>
  
                                                        <EditFormSettings>
                                                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                            </EditColumn>
                                                        </EditFormSettings>
  
                                                    </MasterTableView>
                                                    <FilterMenu EnableTheming="True" Skin="WebBlue">
                                                        <CollapseAnimation Duration="200" Type="OutQuint" />
                                                    </FilterMenu>
                                                </telerik:RadGrid>

Here is my delete click
protected void btnDelete_Click(object sender, EventArgs e)
        {

                var

 

 

dataItem = (sender as ImageButton).NamingContainer as GridDataItem;

 

 

 

 

                foreach (EntityUserRole item in DataSource)

 

 

 

                    if (int.Parse(dataItem.GetDataKeyValue("EntityID").ToString()) == item.EntityID)

 

                    {

                        DataSource.Remove(item);

                        BindDataGrid();

 

 

                        break;

 

                    }


            foreach (GridDataItem row in dgLoginRequest.MasterTableView.Items)
            {
                var entityID = (int) row.GetDataKeyValue("EntityID");
                var chbxReader = (CheckBox) row.FindControl("chbxReader");
                var chbxRKDropbox = (CheckBox) row.FindControl("chbxRKDropbox");
                var chbxPrivateReader = (CheckBox) row.FindControl("chbxPrivateReader");
                var chbxShare = (CheckBox) row.FindControl("chbxShare");
                chbxReader.Enabled = false;
                chbxRKDropbox.Enabled = false;
            }
        }

 

 

public void BindDataGrid()

 

{

    dgLoginRequest.DataSource = DataSource;

    dgLoginRequest.DataBind();

}




Why aren't these checkboxes being disabled?

1 Answer, 1 is accepted

Sort by
0
Dan Harvey
Top achievements
Rank 2
answered on 30 Mar 2012, 12:03 AM
I figured out the issue.  I was rebinding after the enabling.
Tags
Grid
Asked by
Dan Harvey
Top achievements
Rank 2
Answers by
Dan Harvey
Top achievements
Rank 2
Share this question
or