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
15
Databound Multi Column dropdown in WebDataGrid
posted

Hello, 

I have a WebDataGrid bound to a SQL table 'parts' and includes the field 'PartTypeID'

I have a second SqlDataSource, 'SqlDataSource2' for the table 'PartType' which also includes the fields 'PartTypeID', 'TypeCode', Category' and 'Description'

I have a DropDownProvider that I have set DataSourceID to 'SQLDataSource2' , ValueField to 'PartTypeID' and Text field to 'TypeCode'

All the above works fine for updating the table BUT the dropdown only shows 1 column, the 'TypeCode'

How do I get the dropdown to display multiple columns when selected so that the 3 fields are displayed?

Parents
No Data
Reply
  • 1660
    Verified Answer
    Offline posted

    Hello David,

    In order to display multi-column dropdown inside the WebDataGrid, what I can suggest you is using DropDownProvider as an editor component and inside its ItemTemplate to place a WebDataGrid. Since the WebDataGrid inside the ItemTemplate is populated and not the DropDownProvider itself you won’t need to use ValueField and TextField. Instead the data for the WebDataGrid inside the ItemTemplate can be set as follows:

    WebDataGrid templatedGrid = IDDropDown.EditorControl.Items[0].FindControl("WebDataGrid2") as WebDataGrid;

    templatedGrid.DataSource = dt;

    I am attaching a sample that demonstrates this. To be able to set the selected item and update its value a Javascript functions are used. They check if there is a change in the value of the DropDownProvider and update the cell. This is based on the row index inside the grid and the TextField could be simulated depending on which value you wish to be present by choosing which cell index to be displayed.

    Please test the sample on your side and let me know if you have any questions.

    Regards,
    Ivan Kitanov

    MultiColumnDropDownProvider.zip

Children
No Data