国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net 數據綁定的實例代碼

2024-07-10 12:44:48
字體:
來源:轉載
供稿:網友
代碼如下:
public partial class _Default : System.Web.UI.Page
{
    protected string title="大家好";            //前臺代碼<title><%#title %></title>
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        string sql = ConfigurationManager.ConnectionStrings["strsql"].ConnectionString;
        using (SqlConnection sqlCnn=new SqlConnection(sql))
        {
            using (SqlCommand sqlCmm=sqlCnn.CreateCommand())
            {
                sqlCmm.CommandText = "select * from List";
                SqlDataAdapter adapter = new SqlDataAdapter(sqlCmm);
                adapter.Fill(ds);
            }
            this.RadioButtonList1.DataSource = ds.Tables[0];
            this.RadioButtonList1.DataTextField = "listname";
            this.RadioButtonList1.DataValueField = "id";
            //this.RadioButtonList1.DataBind();
            this.CheckBoxList1.DataSource = ds.Tables[0];
            this.CheckBoxList1.DataTextField = "listname";
            this.CheckBoxList1.DataValueField = "id";
            //this.RadioButtonList1.DataBind();
            this.DataBind();
        }            //數據綁定到RadioButtonList,CheckBoxList
        if (!IsPostBack)
        {
            DataSet ds1 = new DataSet();
            using (SqlConnection sqlCnn1 = new SqlConnection(sql))
            {
                using (SqlCommand sqlCmm1 = sqlCnn1.CreateCommand())
                {
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 柳州市| 习水县| 喜德县| 红原县| 永安市| 遵义市| 芷江| 临桂县| 兴隆县| 松江区| 巴林右旗| 青河县| 利辛县| 尉犁县| 临沂市| 榆中县| 普宁市| 定州市| 嘉善县| 资溪县| 肥城市| 溆浦县| 个旧市| 玛纳斯县| 日喀则市| 包头市| 句容市| 兰西县| 游戏| 伊吾县| 洛扎县| 全州县| 承德县| 永修县| 肥乡县| 繁昌县| 封丘县| 宜城市| 宜城市| 浑源县| 昭通市|