Web绑定控件

1.web绑定控件 RadioButtonList,CheckBoxList,DropDownList控件
 if (!Page.IsPostBack)
        {
            string conStr = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString.ToString();
            SqlConnection conn = new SqlConnection(conStr);
            string sqlStr = "SELECT Name FROM PersonInfor";
            SqlCommand cmd = new SqlCommand(sqlStr, conn);
            conn.Open();
            RadioButtonList1.DataSource = cmd.ExecuteReader();
            RadioButtonList1.DataTextField = "Name";
            RadioButtonList1.DataBind();
            conn.Close();
        }

你可能感兴趣的:(Web,String,cmd)