views:

132

answers:

3

I have created a dataset in a project in visual studio that points to a table in my database and then bound a datagridview control to it.

Now I open the database and add another column to the table in the database. Then i open the dataset and update it's configuration to include the change.

Then i want to update the datagridview, but I can't add the new column. I can right click on the tableadapter in the form where the datagridview is and get the correct table data up.

It does not matter if I delete the tableadapter and the bindingsource and dataset instance from the form, and then try and rebind it, the datagridview still won't let me add the new column.

Does anyone have an idea what is happening?
I've tried this with several projects, both VS2008 and 2010 beta, not with other languages than C# tho.
The only solution so far seems to be to make a whole different dataset, but there has to be a better way.

Thanks in advance

A: 

Follow the following steps: 1. Go to dataset and add the new column 2. Go to the databindingsource and modify the query. 3. Go to the datagridview and add the new column

I simulated the same scenario as told by you and it worked.

HotTester
I have a question regarding step 2. It seems a little unclear to me. What exactly do you mean by modify the databindingsource? I did this:1 opened the form with the datagridview in it. 2 right clicked on tblTestTableAdapter (test being my table) and selected "add query". 3 in the builder window I selected to replace and existing query, and made sure the new column name was included and pressed ok. 4 tested i could see the data in "preview data" in VS. right clicked on my datagridview and selected "edit columns". when I press add column in there I can't see my newly added column.
imonsei
I've retraced the steps you've indicated. it still doesnt work for me. it seems like VS is caching the table scheme either in the datagridview or the bindingsource.yet when i preview data for the bindingsource the columns have changed.
imonsei
A: 

Hi,

If you set the GridView AutoGeneratedColumn property to tru it will auto reflect the column, but if you set it to fasle you have to add the markup in aspx page like this between <Columns> Tag

<asp:BoundField DataField="ColumnName" HeaderText="Header Text which you want to for table th " />

I hope this will work for you.

Thanks

Professional2Hire
hey. thanks for taking the time to answer :)unfortunately i'm not working in aspx, im making an old fashioned program. but i will try seeing if i can set the AutoGeneratedColumn to false, build my solution, and then setting it back and seeing if it updates the definitions that way.I'll post here if it works
imonsei
it seems like you can't do that in normal app development. the only way you can do something is to use an unbound column, and that would negate the purpose of the whole thing.
imonsei
A: 

Under the folder in
"C:\Users\YOURUSERNAME\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies"
visual studio has a load of compiled things it uses for quick reference. These are named after some hashing scheme so we can't tell which one is the compiled settings for our botched table scheme.
1. We start by closing Visual Studio (I just did it to be on the safe side)
2. Delete all the folders in the ProjectAssemblies folder.
3. Open up Visual Studio again
4. Rebuild solution
5. And NOW we get the correct values when we add columns to our datagridview.

WHEW! :D

imonsei
Alternately, I found that sometimes just building your solution again does the trick. O_o
imonsei