ASP.Net绑定数据源

1.使用DropDownList手动绑定数据源

       public  void  GetBinds()

         {

              DataTable   tb= GetTable(……);

              this.DropDownList.DataSource=tb;

              this.DropDownList.DataTextField="类别";   //可见值

              this.DropDownList.DataValueField="ID"       //隐藏值

        }

          调用该 方法后记的 加上     this.DataBind();

 

2. 篇历的   ChickBoxList          

for (int i=0; i<checkboxlist1.Items.Count; i++)
         {
            if (checkboxlist1.Items[i].Selected)
            {
               Label1.Text += checkboxlist1.Items[i].Text + "<br />";
            }
         }

 

posted @ 2012-04-16 13:25  酒沉吟  阅读(196)  评论(0编辑  收藏  举报