471,315 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 software developers and data experts.

Multiple tablestyles and one table?

I have one DataTable used in a datagrid. I have multiple TableStyles
to defining various views of the data. The table contains 20 unique
columns. I have four TableStyles, each with containing five columns.
I'd like to switch out these four views on button clicks. One view
will display at a time. Rather than create four datatables, I feel the
tablestyles and switching them is quicker. Comments?

For some reason, it isn't working. I do this in form_load() where dgts
is a gridtablestyle object:
dgtsSummary.MappingName = "Summary";
dggrid.TableStyles.Add(dgtsSummary);

I'm doing this on a button click for testing:
ds.Tables[0].TableName = dgtsSummary.MappingName;
dggrid.Refresh();

Right now, the tablestyle has only one mapped column, which should make
the grid display only that column. However, I'm still seeing all
columns. Each column in the table does have a space. Is the correct
mapping name "[some column]" or just "some column"?

Finally, how do I switch grid views by changing the mappings upon
button clicks?

Thanks,
Brett

Jan 27 '06 #1
1 1079
Ok, here it is:

case 0:
{
dggrid.TableStyles.Clear();
dggrid.TableStyles.Add(gridstyle1);
break;
}
case 1:
{
dggrid.TableStyles.Clear();
dggrid.TableStyles.Add(gridstyle2);
break;
}

Each gridstyle object should have the name of the table your mapping
to.

Brett

Jan 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.