Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing columns in a Datagrid 1

Status
Not open for further replies.

Irritated

Programmer
Mar 9, 2004
8
US
I have a data grid that is created based on a query that is created when a user selects which fields he/she wants included. This works fine except when the user goes back to make a different field selection choice, the column names that they formerly selected still appear on the datagrid. No data appears in these columns, but the name of the column still appears.

For example, the user can select name, address1, city, state, zip. The first time through they select just name and address1. The data grid displays just those two column names and the corresponding data in them. Then the user decides to select different choices, so they return to the selection screen. This time they select name and city. The data grid then displays the column names for name, address1 and city and just the data for name and city. I clear my dataset before filling it again.

Can someone help me to determine what I'm missing?

Thanks.
 
I clear my dataset before filling it again."

Are you just getting rid of the data, or creating a completely new table? It sounds like the schema information is getting left over from the last fill.

You'll either need a completely new DataTable or a call to dataset.Tables[0].Columns.Clear(); or something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top