毛毛的小窝 — 关注技术交流、让我们一起成长

导航

数据绑定技术—将Hashtable绑定到RadioButtonList Web控件

void Page_Load(object sender, System.EventArgs e)
{
    
if(!IsPostBack)
    
{
        
// 创建 Hashtable 对象并填充数据
        Hashtable hash = new Hashtable();
        hash.Add(
"北京""010");
        hash.Add(
"广州""020");
        hash.Add(
"上海""021");
        hash.Add(
"天津""022");
        hash.Add(
"成都""028");
        hash.Add(
"济南""0531");

        
// 进行数据绑定
        RadioButtonList1.DataSource = hash;
        RadioButtonList1.DataTextField 
= "Key";
        RadioButtonList1.DataValueField 
= "Value";
        RadioButtonList1.DataBind();
    }

}

posted on 2006-02-15 16:50  mjgforever  阅读(316)  评论(0编辑  收藏  举报