我在repeater中放了dropdownlist,通过这个dropdownlist选中项,经过后台查询数据重新绑定页面的其他数据,现在问题是,选中后重新绑定必须要经过repeater的ItemDataBound事件,但是这个事件完成以后原本的dropdownlist选中项就空了,不知道怎样控制repeater中dropdownlist选中原本的值,急死了!求助
调试欢乐多
{ BindData();}
<asp:repeater id="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<itemtemplate>
<div>
<asp:dropdownlist id="ddl" autopostback="true" onselectedindexchanged="myDrop_SelectedIndexChanged" runat="server"> </asp:dropdownlist>
</div>
</itemtemplate>
</asp:repeater> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
{
DropDownList myDrop = e.Item.FindControl("ddl") as DropDownList;
}
} protected void myDrop_SelectedIndexChanged(object sender,EventArgs e)
{
Response.Write(((DropDownList)sender).SelectedIndex.ToString());
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
{
DropDownList myDrop = e.Item.FindControl("ddl") as DropDownList;
myDrop.Items.FindByValue("应该绑定的数据值").Selected = true;
}
}