-1
的html代碼:如何獲取datalist中更改的值下拉列表?
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" OnItemDataBound="DataList1_ItemDataBound" OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
<ItemTemplate>
<asp:DropDownList ID="listedad" data-max="30" runat="server" OnSelectedIndexChanged="DataList1_SelectedIndexChanged">
後面我的代碼:
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
int tedadkala = Convert.ToInt32(((DropDownList)e.Item.FindControl("listedad")).Text);
int gheymat =
Convert.ToInt32(((Label)e.Item.FindControl("lblvahed")).Text);
int batedad = gheymat * tedadkala;
((Label)e.Item.FindControl("lblhesab")).Text = batedad.ToString();
((Label)e.Item.FindControl("lblhesab")).DataBind();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
它只有當頁面加載正在擔心,但我改變下拉列表後: –
我不能使用dropdown_textchange事件因爲在數據列表中,我真的需要你的幫幫我 –