We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set default value on add row

Thread ID:





104288 Jul 8,2012 02:24 PM UTC Aug 24,2012 10:02 AM UTC ASP.NET Web Forms (Classic) 1
Tags: GridGroupingControl
Asked On July 8, 2012 02:24 PM UTC


I have i row with a Dropdown  EditItemTemplate in one column and 3 TextBox in other 3 columns always as EditItemTemplate. I need to set a dynamic default value for each textbox when i change the selected item in the dropdown. How i can do it? I tried with record.setValue on selectindexchanged event but it doesn't work.

An another question: How i can find the ItemTemplate control with FindControl property? I tried this ggc.FindControl("id") but i don't find my control


Yogeshwaran [Syncfusion]
Replied On August 24, 2012 10:02 AM UTC

Hi Fabio,


Thanks for using Syncfusion products.


Query #1:  I need to set a dynamic default value for each textbox when change the selected item in the dropdown. How can i do it?


 1)This can achieved in dropdown “OnSelectedIndexChanged” event. Please find the following code snippet.


protected void drop1_TextChanged(object sender, EventArgs e)


Control control = ((DropDownList)sender).NamingContainer.Parent;

TextBox IDtext =  (TextBox)FindControlRecursive(control, "ID");

if (IDtext != null)

IDtext.Text = list[((DropDownList)sender).SelectedIndex - 1].ID.ToString();

TextBox CurrencyText = (TextBox)FindControlRecursive(control, "Currency");

if (CurrencyText != null)

CurrencyText.Text = list[((DropDownList)sender).SelectedIndex - 1].Currency.ToString();

TextBox TelephoneText = (TextBox)FindControlRecursive(control, "Telephone");

if (TelephoneText != null)

TelephoneText.Text = list[((DropDownList)sender).SelectedIndex - 1].Telephone.ToString();





 2) In some asp.net controls don’t have default autopostback as true . So we have to enable AutoPostBack as true to trigger postback event. Please find the code snippet.


                                 <asp:DropDownList ID="drop1" runat="server" EnableViewState="true" OnSelectedIndexChanged="drop1_TextChanged" AutoPostBack="true">


  Query #2: How  can i find the ItemTemplate control with FindControl property?


             You can use custom method to find your control . please find the method


Control FindControlRecursive(Control parent, string id)


                                    Control ctrl = parent.FindControl(id);

                    if (ctrl == null && parent.HasControls())


 foreach (Control c in parent.Controls)


                                                         ctrl = FindControlRecursive(c, id);

                        if (ctrl != null) return ctrl;



     return ctrl;




For your convenience , we have created the sample and the same can be downloaded from below link.




Please let us know if you have any concerns.



Yogesh R


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon