当前位置: 代码迷 >> ASP.NET >> 获取 SelectedValue 值有关问题
  详细解决方案

获取 SelectedValue 值有关问题

热度:10447   发布时间:2013-02-25 00:00:00.0
获取 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


对的