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

enabling checkbox in grid

1 Answer 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hchattaway
Top achievements
Rank 1
hchattaway asked on 29 May 2008, 06:02 PM
Hello

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:

  this.DataSource = lookUpValues; 
                this.Width = 200; 
                this.MasterTableView.DataKeyNames = new string[] { "LuTableValueID" }; 
                this.AutoGenerateColumns = false
 
                GridCheckBoxColumn  selectCheckbox; 
                selectCheckbox = new GridCheckBoxColumn(); 
                selectCheckbox.HeaderText = "Select"
                selectCheckbox.UniqueName = "selectedValue"
                selectCheckbox.DataField = "selectValue"
                this.MasterTableView.Columns.Add(selectCheckbox); 
                 
                GridBoundColumn descColumn; 
                descColumn = new GridBoundColumn(); 
                descColumn.DataField = "Description"
                descColumn.HeaderText = "Description"
                this.MasterTableView.Columns.Add(descColumn); 
                this.ClientSettings.Selecting.AllowRowSelect = true
                //this.AllowMultiRowSelection = true; 
                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.

Thanks!
Harold

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 May 2008, 05:01 AM
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.

ASPX:
 
 
<rad:GridTemplateColumn> 
  <ItemTemplate> 
     <asp:CheckBox id="defaultChkBox" runat="server" 
     Checked='<%# Eval("Bool") %>'>  
   </asp:CheckBox> 
  </ItemTemplate> 
</rad:GridTemplateColumn> 
 
 


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