Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Databind to a dropdownlist in a webgrid
posted

I have a column that is set as a dropdownlist type. How do I bind that dropdownlist to a datasource.  I have tried 'column.valuelist.datasource = dataset', but nothing shows up, even when I click on a cell. I am doing all this programmatically. The only thing that is not programmatically is the column which I created in the designer.

  • 8680
    posted

    eware said:
    I have tried 'column.valuelist.datasource = dataset'

    You also need to set:

    column.ValueList.DataMember = MyDropDownTable
    column.ValueList.DisplayMember = MyDropDownTextColumn
    column.ValueList.ValueMember = MyDropDownValueColumn

    where MyDropDownTable is the name of the table containing the dropdown data*, MyDropDownTextColumn is the name of the column containing the text options to be displayed in the dropdown, and MyDropDownValueColumn is the name of the column containing the values to be returned.

    * or you could use:

    column.valuelist.datasource = dataset.tables(N)