K
Kevin
Hi
I need to get the "ItemId" from the selected value of the DropDownList in a
DataList, but i don't known where tu put the <%#
DataBinder.Eval(Container.DataItem, "ItemId"), because if I try to put in
the ID of the DropDownList generate an error. I've used this code, i catch
the SelectedIndexChange.
HTML:
<aspataList id="dlDropDownList" runat="server">
<ItemTemplate>
<span><%# DataBinder.Eval(Container.DataItem, "ItemName")%></span>
<aspropDownList Runat="server" OnSelectedIndexChanged="SetRanking"
AutoPostBack="True">
<asp:ListItem>
1
</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</aspropDownList>
</ItemTemplate>
</aspataList>
Codebehind:
protected void SetRanking(object sender, System.EventArgs e)
{
DropDownList CurrentDDL;
int SelectedValue;
CurrentDDL = (DropDownList)sender;
SelectedValue = Convert.ToInt32(CurrentDDL.SelectedItem.Text);
//I need some way to get the ItemId to update
}
Thanks
I need to get the "ItemId" from the selected value of the DropDownList in a
DataList, but i don't known where tu put the <%#
DataBinder.Eval(Container.DataItem, "ItemId"), because if I try to put in
the ID of the DropDownList generate an error. I've used this code, i catch
the SelectedIndexChange.
HTML:
<aspataList id="dlDropDownList" runat="server">
<ItemTemplate>
<span><%# DataBinder.Eval(Container.DataItem, "ItemName")%></span>
<aspropDownList Runat="server" OnSelectedIndexChanged="SetRanking"
AutoPostBack="True">
<asp:ListItem>
1
</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</aspropDownList>
</ItemTemplate>
</aspataList>
Codebehind:
protected void SetRanking(object sender, System.EventArgs e)
{
DropDownList CurrentDDL;
int SelectedValue;
CurrentDDL = (DropDownList)sender;
SelectedValue = Convert.ToInt32(CurrentDDL.SelectedItem.Text);
//I need some way to get the ItemId to update
}
Thanks