Hi,
I am trying to make a GridBoundColumn in the radgrid not to be visible when in insert mode.
I was able to make the textbox for the column to behave not to be visible. But the label attached to it is still visible.
I did as below to make the textbox not to be visible in the itemdatabound event ,
How to make the label attached to it also not to be visible?
Please help. Urgent
Regards
Sujith
I am trying to make a GridBoundColumn in the radgrid not to be visible when in insert mode.
I was able to make the textbox for the column to behave not to be visible. But the label attached to it is still visible.
I did as below to make the textbox not to be visible in the itemdatabound event ,
if
(e.Item is GridEditFormInsertItem && e.Item.IsInEditMode)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
TextBox
txtDesc = (TextBox)insertItem["Description"].Controls[0];
txtDesc.Visible = false;
How to make the label attached to it also not to be visible?
Please help. Urgent
Regards
Sujith
4 Answers, 1 is accepted
0
Hi Sujith,
I'd suggest you to use the ReadOnly property. Here is an example:
The column will be displayed in browser mode but will not appear in the edit-form.
Best wishes,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I'd suggest you to use the ReadOnly property. Here is an example:
<telerik:GridBoundColumn |
DataField="MyDataField" |
UniqueName="MyDataField" |
HeaderText="MyDataField" |
ReadOnly="true"> |
</telerik:GridBoundColumn> |
The column will be displayed in browser mode but will not appear in the edit-form.
Best wishes,
Plamen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 01 Sep 2008, 12:05 PM
Hi Sujith,
Try the following code snippet to achieve the desired scenario.
CS:
Regards
Princy.
Try the following code snippet to achieve the desired scenario.
CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridItem item in RadGrid1.MasterTableView.Items) |
{ |
if ((item.OwnerTableView.IsItemInserted) && (!item.IsInEditMode)) |
{ |
foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) |
{ |
if ((col.UniqueName == "FirstName") && (col.ColumnType == "GridBoundColumn")) |
{ |
GridBoundColumn bndCol = (GridBoundColumn)col; |
bndCol.ReadOnly = true; |
} |
} |
} |
else if ((item.Edit) && (!item.OwnerTableView.IsItemInserted)) |
{ |
if (item is GridEditableItem) |
{ |
GridEditableItem edititem = (GridEditableItem)item; |
foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) |
{ |
if ((col.UniqueName == "FirstName") && (col.ColumnType == "GridBoundColumn")) |
{ |
GridBoundColumn bndCol = (GridBoundColumn)col; |
bndCol.ReadOnly = false; |
} |
} |
} |
} |
} |
RadGrid1.Rebind(); |
} |
Regards
Princy.
0
VS
Top achievements
Rank 1
answered on 01 Sep 2008, 12:42 PM
Hi Plamen,
I want to display that column when in edit mode and not to display when am trying to add a new record.
i was able to make the textbox to visible false when in insert mode but the label attached to that column is still visible.
Regards
Sujith
I want to display that column when in edit mode and not to display when am trying to add a new record.
i was able to make the textbox to visible false when in insert mode but the label attached to that column is still visible.
Regards
Sujith
0
Shinu
Top achievements
Rank 2
answered on 02 Sep 2008, 05:24 AM
Hi Sujith,
From what I understood hiding the headertext is not possible with auto-generated edit form type. I would suggest you to use WebUserControl custom edit form which allows you more flexible layout for the edit form.
You can also go through the following forum discussion on this regard.
ItemCommand InitInsert Hide Columns
Thanks
Shinu
From what I understood hiding the headertext is not possible with auto-generated edit form type. I would suggest you to use WebUserControl custom edit form which allows you more flexible layout for the edit form.
You can also go through the following forum discussion on this regard.
ItemCommand InitInsert Hide Columns
Thanks
Shinu