9 Answers, 1 is accepted

One suggestion will be to access the CheckBox from the insert form when the Grid is in the Insert mode and set its display to none. So that when you perform an Insert operation it will insert 0 value for the CheckBox. Here is the code I implemented to hide the CheckBox:
ASPX:
<telerik:GridCheckBoxColumn UniqueName="CheckCol" DataField="Discontinued" HeaderText="CheckCol" ></telerik:GridCheckBoxColumn> |
CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if ((e.Item is GridDataInsertItem) && (e.Item.OwnerTableView.IsItemInserted == true)) |
{ |
GridDataInsertItem insertItem = (GridDataInsertItem)e.Item; |
CheckBox chkbx = (CheckBox)insertItem["CheckCol"].Controls[0]; |
chkbx.Style.Add("display","none"); |
} |
} |
Regards
Shinu.

Hello Shinu
First of all, thanks for your answer and your time! And Sorry for my late reply..
I have a question for you, if I have a hierarchical datagrid and the field we are talking about is in the second detail table, do I have to change something in your code as it doesn't enter in the if statement....
Thanks in advance

You can access the checkbox during InsertMode of DetailTable by naking use of the DetailTables name property as shown below:
aspx:
<telerik:RadGrid ID="RadGrid2" runat="server" OnItemDataBound="RadGrid2_ItemDataBound" > |
<MasterTableView Name="Master"> |
<DetailTables > |
<telerik:GridTableView DataSourceID="SqlDataSource1" AllowPaging="False" Name="Detail1" runat="server" > |
<DetailTables> |
<telerik:GridTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" Name="Detail2" EditMode="InPlace" > |
cs:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if ((e.Item is GridDataInsertItem) && (e.Item.OwnerTableView.IsItemInserted == true) && (e.Item.OwnerTableView.Name=="Detail2")) |
{ |
GridDataInsertItem insertItem = (GridDataInsertItem)e.Item; |
CheckBox chkbx = (CheckBox)insertItem["CheckCol"].Controls[0]; |
chkbx.Style.Add("display", "none"); |
} |
} |
Thanks
Princy.

Unfortunely this doesn't work with
EditMode
="EditForms"
But it kind of work with InLine EditMode. I say "kind of work" because it shows the column but hide the checkbox. So I see the header of the column. Anyway, I use EditForms mode everywhere so I would really like to have a way to do this with this mode...
Do you have any solution?
Thanks again

Thanks

ok, Now it enter in the itemDatabound. Here is my code
If
(TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted = True) AndAlso (e.Item.OwnerTableView.Name = "GTVOffre") Then
Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
Dim chkbx As CheckBox = DirectCast(insertItem("COURRIEL_ENVOYE").Controls(0), CheckBox)
chkbx.Style.Add("display", "none")
The problem I got is that it hide the checkbox in insert mode but it shows the label beside...
Does it has a way to hide the checkbox and its label in insert mode?
Thanks again!

Please test the following modification:
insertItem("COURRIEL_ENVOYE").Parent.Visible = False |
I hope this helps.
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

That's solved my issue!
Thanks!