mercredi 28 octobre 2015

how to create Dynamic check-box list with 3 options in C#

CheckBox list for languages skills

I need to create check-box list dynamically populated from database. I have no problem with creating this with the single option but with 3 - kind of puzzle me. Currently I have following code which create single colum of checkboxes with Language name:

public void CreateCheckBox(DataSet DSDataForCheckBox, string pLangGrp)
    {
        CheckBoxList chkList = new CheckBoxList();
        chkList.ID = "LanguageList";
        chkList.AutoPostBack = true;
        chkList.DataSource = DSDataForCheckBox;
        chkList.DataTextField = "LangName";
        chkList.DataValueField = "LangID";
        chkList.DataBind();

        Panel pLang = new Panel();

        if (pLangGrp != "")
        {
            pLang.GroupingText = pLangGrp;

        }
        else
        {
            pLang.GroupingText = "Non Assigned Group";

        }
        pLang.Controls.Add(chkList);
        this.Form.Controls.Add(pLang);

    }

Need your experts help. Thanks

 PS: we are on NET 3.5, so many options from 4.0 is not available for me.



Aucun commentaire:

Enregistrer un commentaire