6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 16 Sep 2010, 03:58 AM
Hello Orlando,
In order to hide a column in EditForm/PopUp edit mode, set the column's ReadOnly propert as true.
ASPX:
Thanks,
Princy.
In order to hide a column in EditForm/PopUp edit mode, set the column's ReadOnly propert as true.
ASPX:
<
telerik:GridBoundColumn
DataField
=
"FirstName"
ReadOnly
=
"true"
Visible
=
"false"
HeaderText
=
"FirstName"
UniqueName
=
"FirstName"
>
</
telerik:GridBoundColumn
>
Thanks,
Princy.
0
Orlando
Top achievements
Rank 1
answered on 20 Sep 2010, 05:58 AM
I understand to set readonly = true will make it 'hidden' in popup forms.
but, the situation is that the hidden field is actually a foreign key fields that gets filled in ItemCommand (see code below), when it's set to visible=false, it works well in InPlace Edit mode, but when it's set to visible=false, ReadOnly=true, and use Popup mode, to save a new record will generate key error, it looks like the value has not been assigned. How shall I handle this?
* HotelID is the foreign key of the RadGrid table, it shall be hidden in all edit mode, and is assigned in the following code.
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled = true;
newValues["HotelID"] = Session["HotelID"];
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
}
but, the situation is that the hidden field is actually a foreign key fields that gets filled in ItemCommand (see code below), when it's set to visible=false, it works well in InPlace Edit mode, but when it's set to visible=false, ReadOnly=true, and use Popup mode, to save a new record will generate key error, it looks like the value has not been assigned. How shall I handle this?
* HotelID is the foreign key of the RadGrid table, it shall be hidden in all edit mode, and is assigned in the following code.
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
e.Canceled = true;
newValues["HotelID"] = Session["HotelID"];
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
}
0
Princy
Top achievements
Rank 2
answered on 20 Sep 2010, 10:29 AM
Hello Orlando,
Give a try with hiding the control only in edit mode, instead of setting the ReadOnly property.
C#:
Thanks,
Princy.
Give a try with hiding the control only in edit mode, instead of setting the ReadOnly property.
C#:
protected
void
RadGrid1_ItemDataBound1(
object
sender, GridItemEventArgs e)
{
if
((e.Item
is
GridEditFormItem && e.Item.IsInEditMode) && !(e.Item
is
GridEditFormInsertItem))
// hide the control in edit mode
{
GridEditFormItem editItem = (GridEditFormItem)e.Item;
TextBox txt = (TextBox)editItem[
"HotelID"
].Controls[0];
txt.Parent.Parent.Visible =
false
;
}
}
Thanks,
Princy.
0
Orlando
Top achievements
Rank 1
answered on 20 Sep 2010, 05:33 PM
This works great!
But why do I need,
&& !(e.Item is GridEditFormInsertItem)?
But why do I need,
&& !(e.Item is GridEditFormInsertItem)?
0
Princy
Top achievements
Rank 2
answered on 21 Sep 2010, 05:33 AM
Hello Orlando,
The above code is for hiding the control only in edit mode. So the conidtion (! e.Item is GridEditFormInsertItem) is for not executing that code when the grid is in insert mode.
Thanks,
Princy.
The above code is for hiding the control only in edit mode. So the conidtion (! e.Item is GridEditFormInsertItem) is for not executing that code when the grid is in insert mode.
Thanks,
Princy.
0
Chillax
Top achievements
Rank 1
answered on 20 Jul 2012, 10:12 AM
Hi Everyone...
Try this...it works for me.
http://like2know.blogspot.com/2012/07/hide-some-of-field-in-grideditmodepopup.html
Regards
Try this...it works for me.
http://like2know.blogspot.com/2012/07/hide-some-of-field-in-grideditmodepopup.html
Regards