2 posts, 0 answers
  1. Joel
    Joel avatar
    165 posts
    Member since:
    Oct 2006

    Posted 16 Dec 2009 Link to this post

    I am not sure of the suggested method on how to accomplish this.  Any assistance would be greatly appreciated.

    I have a grid bound to a boolean field.  If the item value is 1, I want he checkbox checked and read only (GridCheckBoxColumn would work here).  If the item value is 0, I want the checkbox enabled (GridCheckBoxColumn doesn't seem to work for this) and a postback when the user checks the box so I can update the database and rebind the two grids on the page.

    In short, I want it so checks can never be removed, only added, and only one item checked per postback.  Grid is bound with NeedDataSource event.

    Any suggestions?

    Here is what I have now.  When it is done, I only want to have one column of checkboxes, the three below are all tests.

                <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" 
                    GridLines="None" Height="500" BorderWidth="0" AllowSorting="true" Style="outline: none" 
                    ShowGroupPanel="false" AllowPaging="true" AllowFilteringByColumn="false"
                    <ClientSettings Scrolling-AllowScroll="True" Scrolling-UseStaticHeaders="true" Selecting-AllowRowSelect="true" 
                        EnablePostBackOnRowClick="true"  EnableRowHoverStyle="true" 
                        ClientEvents-OnRowSelected="RowSelected" > 
                    <MasterTableView TableLayout="Fixed"  GroupLoadMode="Client" DataKeyNames="job_id" > 
                        <telerik:GridCheckBoxColumn DataField="isChecked" ReadOnly="false" HeaderText="My Job1" HeaderStyle-Width="60" UniqueName="mycheck1" ></telerik:GridCheckBoxColumn> 
                        <telerik:GridClientSelectColumn HeaderText="My Job2"  HeaderStyle-Width="60" UniqueName="mycheck2"></telerik:GridClientSelectColumn> 
                        <telerik:GridTemplateColumn HeaderText="Check/UnCheck"   UniqueName="TemplateColumn"
                                <asp:CheckBox id="editChkBox" runat="server" AutoPostBack="true" 
                                 Checked='<%# Bind("ischecked") %>' Enabled="true"
                                 <asp:CheckBox id="defaultChkBox" runat="server" Enabled="true" 
                                 Checked='<%# Eval("ischecked") %>'
                        <telerik:GridBoundColumn DataField="user_id" Headertext="userid" Visible="false"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="username" HeaderText="Username" HeaderStyle-Width="120px"
                            <telerik:GridBoundColumn DataField="Title" HeaderText="Title" > 

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Dec 2009 Link to this post

    Hello Joel,

    Try out the following code using a GridCheckboxColumn to achieve the required sceanrio:

    <telerik:GridCheckBoxColumn DataField="Condition" UniqueName="CheckBoxColumn" HeaderText="CheckBox Column"

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
            if (e.Item is GridDataItem) 
                GridDataItem item = (GridDataItem)e.Item; 
                CheckBox chk = (CheckBox)item["CheckBoxColumn"].Controls[0]; 
                chk.Enabled = !chk.Checked; 
                chk.AutoPostBack = true

    Hope this helps..
  3. DevCraft R3 2016 release webinar banner
Back to Top