enabling checkbox in grid

2 posts, 0 answers
  1. hchattaway
    hchattaway avatar
    67 posts
    Member since:
    Feb 2007

    Posted 29 May 2008 Link to this post


    I am using the Q1 2008 build of the controls for Ajax (Prometheus) and am trying to embed a checkbox in a grid that will be used as a multiselect control. The checkbox is bound to a BIT field. I ma creating the grid programmatically.

    Here is the code:

    1   this.DataSource = lookUpValues; 
    2                 this.Width = 200; 
    3                 this.MasterTableView.DataKeyNames = new string[] { "LuTableValueID" }; 
    4                 this.AutoGenerateColumns = false
    6                 GridCheckBoxColumn  selectCheckbox; 
    7                 selectCheckbox = new GridCheckBoxColumn(); 
    8                 selectCheckbox.HeaderText = "Select"
    9                 selectCheckbox.UniqueName = "selectedValue"
    10                 selectCheckbox.DataField = "selectValue"
    11                 this.MasterTableView.Columns.Add(selectCheckbox); 
    13                 GridBoundColumn descColumn; 
    14                 descColumn = new GridBoundColumn(); 
    15                 descColumn.DataField = "Description"
    16                 descColumn.HeaderText = "Description"
    17                 this.MasterTableView.Columns.Add(descColumn); 
    18                 this.ClientSettings.Selecting.AllowRowSelect = true
    19                 //this.AllowMultiRowSelection = true; 
    20                 this.DataBind(); 
     this is code in a class that inherits from "RadGrid".

    The checkbox is displayed in the grid, but is not clickable. I have read in the docs "When the grid is in browser mode, or if the column is read-only, the check box is disabled. When the column is editable, the check box is enabled." But how to do that?? make it editable in line? I am not looking to bring up another form to edit the row.

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

    Posted 30 May 2008 Link to this post

    Hi Harold,

    GridCheckBoxColumn can be bound directly to a boolean field in the grid data source (setting the DataField property of that column). The checkbox in GridCheckBoxColumn will be disabled in regular mode. It will be editable in edit and insert mode of grid row. You can use GridTemplateColumn with a CheckBox in its ItemTemplate to achieve the desired effect.

         <asp:CheckBox id="defaultChkBox" runat="server" 
         Checked='<%# Eval("Bool") %>'>  

Back to Top