How do I set the default value to checked when inplace editing a GridCheckboxColumn? Is this possible or would I have to use a template column with a checkbox set to checked? Also are there any examples of using a dropdownlistcolumn?
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2008, 04:44 AM
Hi Jonathan,
Try the following code snippet to set the value of the CheckBox column to be Checked in edit mode.
ASPX:
CS:
Refer the following help article to get details on configuring a GridDropDownColumn.
Customize/Configure GridDropDownColumn
Thanks
Shinu
Try the following code snippet to set the value of the CheckBox column to be Checked in edit mode.
ASPX:
| <telerik:GridCheckBoxColumn DataField="Passed" DataType="System.Boolean" HeaderText="Passed" |
| SortExpression="Passed" UniqueName="Passed"> |
| </telerik:GridCheckBoxColumn> |
CS:
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) |
| { |
| GridEditableItem edititem = (GridEditableItem)e.Item; |
| CheckBox chkbx = (CheckBox)edititem["Passed"].Controls[0]; |
| chkbx.Checked = true; |
| } |
| } |
Refer the following help article to get details on configuring a GridDropDownColumn.
Customize/Configure GridDropDownColumn
Thanks
Shinu
0
Jonathan
Top achievements
Rank 1
answered on 22 Sep 2008, 06:18 AM
Thanks Shinu,
I should be more specific.. I only want the default value to be set when inserting a new item. When editing an item it will be set based on the datasource of the bound item. Will your solution take this scenario into account?
I should be more specific.. I only want the default value to be set when inserting a new item. When editing an item it will be set based on the datasource of the bound item. Will your solution take this scenario into account?
0
Princy
Top achievements
Rank 2
answered on 22 Sep 2008, 07:05 AM
Hello Jonathan,
If you want to set the default value of the checkbox column in InsertMode only then try the following code.
cs:
Thanks
Princy.
If you want to set the default value of the checkbox column in InsertMode only then try the following code.
cs:
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) |
| { |
| GridEditFormInsertItem edititem = (GridEditFormInsertItem)e.Item; |
| CheckBox chkbx = (CheckBox)edititem["Passed"].Controls[0]; |
| chkbx.Checked = true; |
| } |
| } |
Thanks
Princy.
0
Jonathan
Top achievements
Rank 1
answered on 05 Jul 2009, 10:42 PM
Hi Princy.
I am using in-place editing and inserting not using an edit form.
never evaluates to true when entering insert mode.
ANy thoughts.
Cheers
Jonathan
I am using in-place editing and inserting not using an edit form.
| if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted)) |
| { |
never evaluates to true when entering insert mode.
ANy thoughts.
Cheers
Jonathan
0
Jonathan
Top achievements
Rank 1
answered on 05 Jul 2009, 11:03 PM
OK this works:
| protected void radGridLookups_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| if (e.Item.OwnerTableView.IsItemInserted) |
| { |
| GridEditableItem edititem = (GridEditableItem)e.Item; |
| CheckBox chkbx = (CheckBox)edititem["Active"].Controls[0]; |
| chkbx.Checked = true; |
| } |
| } |
| } |