This is a migrated thread and some comments may be shown as answers.

Issue with choosing a New DataSource for my GridView

4 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert LeGood
Top achievements
Rank 1
Robert LeGood asked on 22 Aug 2012, 08:57 PM
I looked through the forums and haven't see anything on this, so I thought I'd post a new post to see if there's an answer or a work-around for my issue.

Summary:  If I, at runtime, choose a new DataSource that shares common Column Names with my current DataSource, only the columns with shared names are shown.  If there are no shared column names, then all columns are displayed.  Note, that I've only tried this with DataTable objects.

How to Reproduce:  Given the following four DataTables (with column names listed.)

TableA : (ID, NAME, DESC)
TableB : (ID, NAME, LOCATION)
TableC : (ITEMID, COUNT)
TableD : (NAME, COUNT)

a) RadGridView.DataSource = "TableA" -> All columns are shown.
b) RadGridView.DataSource = "TableB" -> Only ID and NAME are shown
c) RadGridView.DataSource = "TableC" -> All columns are shown.
d) RadGridView.DataSource = "TableD" -> Only COUNT is shown.

If this is a bug, would you happen to know of a workaround in the meantime?

If you need more information, please let me know.

Thanks!

Rob


4 Answers, 1 is accepted

Sort by
0
Accepted
Don
Top achievements
Rank 1
answered on 22 Aug 2012, 09:44 PM
Are you clearing the DataSource property between changes in the table you're binding to? I do something similar to the following for grids that can have more than a single DataSource:

            Using GridName.DeferRefresh
 
              GridName.MasterTemplate.Reset()
              GridName.DataSource = Nothing
.
.                    Other code here
.
            End Using

GridName is the name of the grid being used, resetting the MasterTemplate clears column information and setting the DataSource to Nothing basically finishes cleaning out the grid. Of course, I may be doing everything wrong, but it's been working well
0
Robert LeGood
Top achievements
Rank 1
answered on 22 Aug 2012, 09:47 PM
Perfect, thanks!
0
Don
Top achievements
Rank 1
answered on 22 Aug 2012, 10:08 PM
My pleasure, Robert!
0
Stefan
Telerik team
answered on 27 Aug 2012, 11:06 AM
Hi guys,

Thank you both for writing.

I have investigated this case and it seems that there is an issue. All columns should be shown when the second data source is assigned and when the grid's AutoGenerateColumns property is true (default value). I have logged this case in our Public Issue Tracking System and we will address it accordingly. Feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/public/winforms/12453.

@Robert - your Telerik Points have been updated for this report.

Using DeferRefresh in this case is not needed since when the DataSource is assigned it is internally called. Furthermore, you should not need to set the DataSource to Nothing too. However, to work around the issue, you should call the Reset method of the template.

I hope that you guys find this information useful. Let us know if you need anything else.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Robert LeGood
Top achievements
Rank 1
Answers by
Don
Top achievements
Rank 1
Robert LeGood
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or