hi,
FindControl
needs to know which Item it is looking in because a
DataLis
t contains many copies of each control that is in a template.You need to iterate all items in
DataLis
t to find the dropdown and manipulate them, you can use the code below,
foreach(DataListItem dlistItem in DataList1.Items)
{
DropDownList ddlcountry= dlistItem.item[i].
findControl("ddlcountry") as DropDownList;
if(ddlcountry!=null)
{
int id=Convert.ToInt32(ddlcountry.SelectedValue);
}
}
Hope this will help.