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

[Solved] How to find controls from EditFormSettings.FormTemplate

7 Answers 743 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Azad
Top achievements
Rank 1
Azad asked on 20 Oct 2008, 04:27 PM
Hi all,
I have some problem with Telerik RadGrid
I want to get control on EditFormSettings.FormTemplate from C# code to can manipulate FormSettings items.
Tanks.

7 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Oct 2008, 06:08 AM
Hi Azad,

Here is an example for ItemCreated/UpdateCommand:

if(e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
    Control yourControl = e.Item.FindControl("YourControlID");
}

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
areen
Top achievements
Rank 1
answered on 25 Feb 2011, 07:03 PM
how do i find the control if i get passed a griddataitem instead from the itemcommand? when i call it from insert, it passes a grideditform item. when i call it from update, it passes a griddataitem.
0
Princy
Top achievements
Rank 2
answered on 28 Feb 2011, 10:30 AM
Hello Areen,

You can set different CommandName for the button in insert/edit form and in ItemCommand event check for the CommandName and access corresponding grid item.

ASPX:
<asp:Button runat="server" ID="btnLoadBalancer" Text="Get Geographic Data"
CommandName='<%# (Container is GridEditFormInsertItem) ? "GeoLookupInsert" : "GeoLookupUpdate" %>' />

C#:
protected void RadGrid4_ItemCommand(object sender, GridCommandEventArgs e)
   {
       if (e.CommandName == "GeoLookupInsert")
       {
          // button in insert form
       }
       if (e.CommandName == "GeoLookupUpdate")
       {
           // button in edit form
       }
   }

Thanks,
Princy.
0
areen
Top achievements
Rank 1
answered on 28 Feb 2011, 08:04 PM
Princy,

While you're feedback is much appreciated, it doesn't answer my question. I did as you suggested and the "Update" path is still returning a GridDataItem to me. how do I get to my form controls from the GridDataItem?

Thanks,
Areen
0
Scott Marx
Top achievements
Rank 1
answered on 30 Nov 2011, 09:00 PM
bump
1
Shinu
Top achievements
Rank 2
answered on 01 Dec 2011, 05:23 AM
Hello Scott,

Try the following code.
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;
   TextBox txt = (TextBox)item.FindControl("TextBox1");
 }
}

-Shinu.
0
Priya
Top achievements
Rank 1
answered on 18 Apr 2013, 05:31 AM
Hi Azad,
thank u....very helpful....
Tags
Grid
Asked by
Azad
Top achievements
Rank 1
Answers by
Vlad
Telerik team
areen
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Scott Marx
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Priya
Top achievements
Rank 1
Share this question
or