ok, ive had a few questions on this subject, i hope Im clearer this time.
I want to find the values from a number of dropdown controls inside a repeater control. I eventually want to build a multidimensional array, so I can loop through each item and add them to a database table.
<asp:Repeater ID="myRepeater" runat="server">
<ItemTemplate>
<asp:DropDownList ID="AdTitle" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="Miss" Text="Miss"/>
<asp:ListItem Selected="False" Value="Ms" Text="Ms"/>
<asp:ListItem Selected="False" Value="Mrs" Text="Mrs"/>
<asp:ListItem Selected="False" Value="Mr" Text="Mr"/>
<asp:ListItem Selected="False" Value="Other" Text="Other"/>
</asp:DropDownList>
<asp:TextBox ID="AdFullName" runat="server"></asp:TextBox>
</ItemTemplate>
<ItemTemplate>
<asp:DropDownList ID="AdTitle" runat="server">
<asp:ListItem Selected="True" Value="" Text=""/>
<asp:ListItem Selected="False" Value="Miss" Text="Miss"/>
<asp:ListItem Selected="False" Value="Ms" Text="Ms"/>
<asp:ListItem Selected="False" Value="Mrs" Text="Mrs"/>
<asp:ListItem Selected="False" Value="Mr" Text="Mr"/>
<asp:ListItem Selected="False" Value="Other" Text="Other"/>
</asp:DropDownList>
<asp:TextBox ID="AdFullName" runat="server"></asp:TextBox>
</ItemTemplate>
You would need to loop through the repeater items and get each value. Code sample below is in C#, but should be able to convert to VB.NET relatively easily.
foreach (RepeaterItem ri in myRepeater.Items)
{
switch (ri.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
DropDownList AdTitle = (DropDownList) ri.FindControl("AdTitle");
TextBox AdFullName = (TextBox) ri.FindControl("AdFullName");
string selectedAdTitle = AdTitle.SelectedValue;
string enteredAdFullName = AdFullName.Text;
// Do something with values here
break;
}
}