G
Guest
I am trying to access a DropDownList control inside a repeater using
ItemCommand as shown below but for some reason i can't access the
DropDownList. When i step through the debug i get <undefine value> for the
DropDownList
What am i doing wrong?
<asp:Repeater ID="Repeater1" Runat="server" OnItemDataBound="create_ddl"
OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
<table>
<tr>
Edit Details
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp
ropDownList ID="ddl" Runat="server"></asp
ropDownList>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="StaffComments" Runat="server"
TextMode="MultiLine" Text='<%# DataBinder.Eval(Container.DataItem,
"StaffPriority")%>' Width="400" Height="40"></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td colspan="2"><asp:Button runat="server" Text="Save
Changes"></asp:Button></td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
public void Repeater1_ItemCommand(object s, RepeaterCommandEventArgs e)
{
DropDownList ddl1 = (DropDownList)e.Item.FindControl("ddl");
if(ddl1 !=null)
{
Response.Write(ddl1.SelectedIndex.ToString());
}
else
{
Response.Write("ddl is null");
}
}
ItemCommand as shown below but for some reason i can't access the
DropDownList. When i step through the debug i get <undefine value> for the
DropDownList
What am i doing wrong?
<asp:Repeater ID="Repeater1" Runat="server" OnItemDataBound="create_ddl"
OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
<table>
<tr>
Edit Details
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="StaffComments" Runat="server"
TextMode="MultiLine" Text='<%# DataBinder.Eval(Container.DataItem,
"StaffPriority")%>' Width="400" Height="40"></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td colspan="2"><asp:Button runat="server" Text="Save
Changes"></asp:Button></td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
public void Repeater1_ItemCommand(object s, RepeaterCommandEventArgs e)
{
DropDownList ddl1 = (DropDownList)e.Item.FindControl("ddl");
if(ddl1 !=null)
{
Response.Write(ddl1.SelectedIndex.ToString());
}
else
{
Response.Write("ddl is null");
}
}