日期:2014-05-18  浏览次数:20436 次

获取 SelectedValue 值问题
我用:
foreach   (TableCell   header   in   this.GridView1.HeaderRow.Cells
DropDownList2.Items.Add(header.Text);
将GridView   Header   的字段添加到DropDownList里,然后选择DropDownList的显示的字段怎么获取其SelectValue值啊???!!谢谢!!!

------解决方案--------------------
DropDownList1.SelectItem.text
------解决方案--------------------

this.DropDownList1.SelectedValue
------解决方案--------------------
his.DropDownList1.SelectedValue
------解决方案--------------------
up~~~~~~~
------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
//键值绑定
ListItem li = new ListItem();
li.Text = e.Row.Cells[i].Text;
li.Value = e.Row.Cells[i].Text;
DropDownList1.Items.Add(li);
}
}
}

//想取DropDownList1的值 现在就直接:
//DropDownList1.SelectedValue 或 DropDownList1.SelectedItem.Value
------解决方案--------------------
//想取DropDownList1的值 现在就直接:
//DropDownList1.SelectedValue 或 DropDownList1.SelectedItem.Value


对的