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.
Template.zip
Please let us know if you have any concerns.
Regards,
Yogesh R