datalist未知列赋值问题
一个datalist中包含了一个DropDownList1和一个label1控件,要实现的功能是当DropDownList1选择项改变时,也就是DropDownList1_SelectedIndexChanged事件下怎么写代码来获取用户选择那个DropDownList1对应label1的值?
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DataList1.SelectedIndex != -1)
{
((Label)DataList1.SelectedItem.FindControl("Label1")).Text = ((DropDownList)DataList1.SelectedItem.FindControl("DropDownList1")).SelectedItem.Value;
}
}