我在中继器内填充下拉列表(DropDownList 填充了数据库中的值)
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string idAdvert = objAdvert.GetAllIlanPage(ClsSession.idUser, null).Rows[i]["ID_ADVERT"].ToString();
DropDownList DDL = (DropDownList)e.Item.FindControl("DropDownList1");
DDL.Items.Add("");
DDL.Items.Add(new ListItem("Doping", idAdvert));
DDL.Items.Add(new ListItem("İşlem", idAdvert));
DDL.SelectedIndex = 0;
i = i + 1;
}
}
它正在工作,但是当我单击下拉列表时,selectedindexchanged 不起作用。它总是发送 selectedIndex=1
protected void SelectedIndex_Degisti(object sender, EventArgs e)
{
//DropDownList ddl = sender as DropDownList;
//DropDownList doldurulacak_ddl = (DropDownList)ddl.Parent.FindControl("DropDownList1");
////Aynı satırdaki doldurulacak diğer droplisti bulduk.
Control parent = ((Control)sender).Parent;
DropDownList GeneralDDL = (DropDownList)parent.FindControl("DropDownList1");
if (GeneralDDL.SelectedItem.Text == "Doping") ;//Response.Redirect("default.aspx");
else if (GeneralDDL.SelectedItem.Text == "İşlem") ;// Response.Redirect("login.aspx");
}