问题:string strName = DropDownList1.Text; //此处的值不是西宁,而是"03",我想得到的是西宁(groupName),
//因为,有利于后面的操作.如何做才能得到??请指点,必给分!! 1.//绑定DropDownList1;
protected void BindDropDwonList1()
{
//得到市级城市列表
BLL.DeviceGroup bllDG = new BLL.DeviceGroup();
DataSet ds1 = bllDG.GetCity(); //此处得到groupName,groupID.比如:西宁,"03"
DropDownList1.Items.Add(new ListItem("请选择", ""));
if (ds1.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds1.Tables[0].Rows)
{
DropDownList1.Items.Add(new ListItem(dr["groupName"].ToString(), dr["groupID"].ToString()));
}
} }
2.
protected void Button1_Click1(object sender, EventArgs e) //确定按钮;
{
string strName = DropDownList1.Text; //此处的值不是西宁,而是"03",我想得到的是groupName,
//如何做才能得到??
DropDownList1.Items.Add(new ListItem(dr["groupName"].ToString(), dr["groupName"].ToString()));
方法2:
string strName = DropDownList1.SelectedItem.Text;
string strName = DropDownList1.SelectedItem.Text