且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

绑定下拉列表中的数据

更新时间:2023-10-04 09:40:16

做到这一点! (如果您有问题,请描述一下,以便我们为您提供实际帮助)
请在此处 [
So do that! (If you have a problem, please describe it so we can actually help you)
Look here[^]here for starters


尝试

Try

private void dropdownlistbind()
    {
       
        SqlCommand cmd = new SqlCommand("Your Command using appropriate clause","Your Connection");
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DropDownList1.DataSource = ds;
        // FieldName of Table in DataBase
        DropDownList1.DataValueField = "FieldName";
        DropDownList1.DataBind();   
      }