在DropDownList中有值域和文本域,在程序开发中经常要确切的绑定两个域。在好多情况下,我们页面显示的是文本,而在数据库存储的是这种文本标 识的整数,如此可以利用Dictionary建立对象,将数据库存储的值与页面显示的值联系起来,进行简单的转换,并且这样还可以实现值或者文本的检索功 能。灵活,很适合进行程序开发。
关键代码:
1DropdownList 绑定hashTable,dictionary        DropDownList1.DataTextField = "value";
2DropdownList 绑定hashTable,dictionary        DropDownList1.DataValueField = "key";
3DropdownList 绑定hashTable,dictionary        DropDownList1.DataSource = getTypeList();
4DropdownList 绑定hashTable,dictionary        DropDownList1.DataBind();

实例代码:
    }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-11-20
  • 2022-02-27
  • 2021-09-12
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-12-24
  • 2021-08-12
  • 2022-12-23
相关资源
相似解决方案