0
我填充的DropDownList在ASP.NET web表單:提交後從下拉列表中獲取選定的值?
<asp:DropDownList runat="server" ID="salesman"></asp:DropDownList>
users= Buslayer.GetSalesRep();
foreach (userentity user in users)
{
salesman.Items.Add(new ListItem(user.FirstName + " " + user.LastName,
user.UserID.ToString()));
}
提交後,我仍然得到選擇指數= 0,
我嘗試了所有的這一點,但失敗:
Response.Write("" + salesman.SelectedValue);
Response.Write("" + salesman.SelectedItem.Value);
Response.Write("" + salesman.SelectedIndex);
我認爲這是不相關的是:如果 (Page.IsPostBack) 的Response.Write( 「」 + salesman.SelectedIndex); if(!Page.IsPostBack) Response.Write(「」+ salesman.SelectedValue); 都不起作用 – Bart 2010-05-17 06:57:33