Datalist gridviewrepeater 數據綁定方法
SqlConnection con=new SqlConnection();
conConnectionString=server=(local);database=YourDataBase;Trusted_Connection=yes;
conOpen();
SqlCommand com=new SqlCommand();
comCommandText=select * from YourTable;
comConnection=con;
DataGridDataSource=comExecuteReader();
//還可以使用數據閱讀器SqlDataReader(不能使用他的構造函數)代碼如下
//SqlDataReader dr=comExecuteReader();
//DataGridDataSource=dr;
//當然還可以使用ADONET的核心數據集和數據適配器;
//SqlDataAdapter ada=new SqlDataAdapter(comCommandTextcon);
//DataSet set=new DataSet();
//adaFill(set);
//DataGridDataSource=set;
//最後計算數據綁定表達式
DataGridDataBind();
Checkboxlistradiobuttonlist 數據綁定
SqlConnection con = new SqlConnection(server=;database=db_Trade;uid=sa;pwd=;);
conOpen();
SqlDataAdapter sda = new SqlDataAdapter(select top * from tb_Speciality con);
DataSet ds = new DataSet();
sdaFill(ds);
thisCheckBoxListDataSource = dsTables[];
thisCheckBoxListDataTextField = speciality_name;
thisCheckBoxListDataValueField = speciality_id;
thisCheckBoxListDataBind();
conClose();
From:http://tw.wingwit.com/Article/program/net/201311/12272.html