绑定下拉框

  public void DropDownListBinding(DropDownList DDList, string sql, string strText, string strField, string str_qxz)
    {

        DataTable dt = MDGL.DBUtility.SQLServerHelper.GetDataTable(CommandType.Text, sql);
        DDList.DataSource = dt;

        DDList.DataValueField = strField;
        DDList.DataTextField = strText;
        DDList.DataBind();
        ListItem NewItem = new ListItem();
        NewItem.Value = "";
        NewItem.Text = str_qxz;
        DDList.Items.Insert(0, NewItem);
    }
    public void DropDownListBinding(DropDownList DDList, string sql, string strText, string strField)
    {

        DataTable dt = MDGL.DBUtility.SQLServerHelper.GetDataTable(CommandType.Text, sql);
        DDList.DataSource = dt;

        DDList.DataValueField = strField;
        DDList.DataTextField = strText;
        DDList.DataBind();
    }
View Code

 

posted on 2013-05-30 14:12  小景  阅读(100)  评论(0编辑  收藏  举报