首页 > 其他 > 详细

DropDownList 数据源绑定和获取

时间:2016-02-29 18:04:09      阅读:185      评论:0      收藏:0      [点我收藏+]

前台代码: 

<td>账户名称:</td>

  <td>

      <asp:DropDownList ID="DropDownListAccount" runat="server" Width="80px"></asp:DropDownList>

   </td>

后端初始化代码:

   private void InitDropDownListAccount()
    {
        DropDownListAccount.Items.Clear();
        List<Account> accountInfo = accountManager.GetAccountInfoList();
        ListItem item = new ListItem("---全部---", "");
        item.Selected = true;
        DropDownListAccount.Items.Add(item);
        foreach (Account account in accountInfo)
        {
            item = new ListItem(account.AccountName, account.AccountID.ToString());
            DropDownListAccount.Items.Add(item);
        }
    }

 

后台 AccountID 获取代码:

string  DropDownListAccount= DropDownListAccount.SelectedValue;

 

DropDownList 数据源绑定和获取

原文:http://www.cnblogs.com/hanxingli/p/5228186.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!