Code snippet for radGrid based on table

2 posts, 0 answers
  1. Karl
    Karl avatar
    226 posts
    Member since:
    Jun 2005

    Posted 20 Dec 2011 Link to this post


    I have an access db with say 20 tables and a radDropDownList showing them. On the event SelectedIndexChanged of the radDropDownList I would like to reconstruct radGrid layout so that the radGrid now reflects the selected table and its data.

    It would be like simulating ms Access but not needing access installed and being able to make a few minor data changes.

    Does anyone have something like this they care to share?


  2. Ivan Petrov
    Ivan Petrov avatar
    707 posts

    Posted 23 Dec 2011 Link to this post

    Hi Karl,

    Thank you for writing.

    One scenario to achieve this is to fill a DataSet with all the tables from the access database and use the data set to bind the grid and drop down. When the user is done editing you can commit the changes back into the database. The provider you use to read/write the data from/to the database is up to you. Once you have the DataSet set up, you can bind the drop down list to the tables collection of the data set. On the SelectedIndexChanged event of the drop down you should bind the grid to a different table from the data set. Please find attached a sample project where I create a DataSet with two tables and mimic the scenario you have described.

    I hope you will find this useful. If you have further questions, I would be glad to help.

    All the best,
    Ivan Petrov
    the Telerik team

    of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top