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

Dynamically change FormTemplate in EditFormSettings

1 Answer 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
De Yan
Top achievements
Rank 1
De Yan asked on 19 Dec 2011, 08:01 AM
I am having problem to display the contents within the form template. I have the following in my rad grid :-

<EditFormSettings EditFormType="Template">
                <FormTemplate>
                    <table id="1" width="100%" border="0" cellpadding="0" cellspacing="10">
                        <tr>
                            <td colspan="3">
                                <span class="des"><asp:Label ID="lblDestination" runat="server" Text='<%# Eval("Destination") %>' /></span>
                            </td>
                        </tr>
..

and I would like to hide the table row based on the DataTable binding. May I know is there any good way of doing this?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Dec 2011, 08:25 AM
Hello,

You can access the controls in FormTemplate as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
    GridEditableItem item = (GridEditableItem)e.Item;
    Label lbl = (Label)item.FindControl("Label1");
      //your condition here
     lbl.Visible = false;
  }
}

-Shinu.
Tags
Grid
Asked by
De Yan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or