Add hidden columns - web datagrid

C

chris

Hello group,
The datagrid I use needs to add a hidden column on demand
(only on certain conditions). The sequence of events would be as below:
1) get the dataset(ds) and bind the datagrid(dg) with
the table corresponding to the ds.
2) Sort the datagrid according to the user selected
columns.

3) Add hidden columns to the datagrid. Here, I am not
sure, how to add hidden columns to the datagrid??

Any help would be great!!

Thanks,
Chris.
 
K

Kevin Yu [MSFT]

Hi Chris,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add hidden columns to a
DataGrid. If there is any misunderstanding, please feel free to let me know.

As far as I know, we can use DataColumn.ColumnMapping = MappingType.Hidden
to achieve this. Here are the steps:

1. Create a new DataColumn object and add to the DataTable.Columns
collection.
2. Set ds.Tables[index].Columns["NewlyAddedCol"].ColumnMapping =
MappingType.Hidden;

Then the columns will be added but not shown in the grid.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
C

Cor Ligthert

Chris,

Not impossible you get an answer here in this newsgroup, so only to give you
an extra possibility, the newsgroups

microsoft.public.dotnet.framework.aspnet.datagridcontrol
and
microsoft.public.dotnet.framework.aspnet
handles questions as yours,

Maybe you find faster and more answers there?

Cor
 
C

Cor Ligthert

Chris,

You got a very nice answer from Kevin when I was answering messages in this
group.

Therefore see my pointing you as existing of those newsgroup for next
problems.

(And when needed because you do not know which is the proper one, you can
maybe crosspost them than to this and those newsgroups, gives you the most
change on answers, crossposting is sending one messages to more newsgroups
in one time)

Cor
 
H

hsaleem

on DataGrid ItemBound event hide the column. If you are using auto
generated columns then you must hide every cell of that column:
e.Item.Cells[1].Visible = false;

if you are using column template then just set the column object
visible property to false.
datagrid1.Columns[1].Visible = false;

regards,
hsaleem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top