By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,707 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,707 IT Pros & Developers. It's quick & easy.

Make columns (fields) invisible dynamically?

P: n/a
I have posted my question before. It seems that I can not find the solution.
The question:
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

The following Possible solution do not work:
dg.Column(3).Visible = false.

My analysis from the test: dg.Column(3).Visible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmatically, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
I have posted my question before. It seems that I can not find the solution.
The question:
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

The following Possible solution do not work:
dg.Column(3).Visible = false.

My analysis from the test: dg.Column(3).Visible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmatically, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #2

P: n/a
I have played your example. It is a very good example to help me for other
checkbox control of cell in a datagrid. I will check your code.

By the way, when you drag the datagrid from toolbox, have you unchecked any
property for it?

Thanks

David

"Phillip Williams" wrote:
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
I have posted my question before. It seems that I can not find the solution.
The question:
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

The following Possible solution do not work:
dg.Column(3).Visible = false.

My analysis from the test: dg.Column(3).Visible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmatically, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #3

P: n/a
Hi David,

The example whose link I provided below was not created using the VS.Net
toolbox at all. It is done using a notepad. The controls are created
dynamically (not placed declaratively on the web form). If you want another
sample that is done declaratively (i.e. you can recreate using the VS.Net)
review this one
http://www.societopia.net/Samples/Da...olsEvents.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
I have played your example. It is a very good example to help me for other
checkbox control of cell in a datagrid. I will check your code.

By the way, when you drag the datagrid from toolbox, have you unchecked any
property for it?

Thanks

David

"Phillip Williams" wrote:
Hi David,

The Column.Visible property works on both declaratively and dynamically
created DataGrid controls. To prove it, I put in this demo
http://www.societopia.net/Samples/Da...Delegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"david" wrote:
I have posted my question before. It seems that I can not find the solution.
The question:
I have datasource, say, ds which is bounded to a datagrid, dg.
Assume that ds have 5 columns, c0,c1,c2,c3,c4.
In some case, say, case 1, I want to display columns c0, c1,c2 in dg and use
c3 and c4 in code behind.
In case 2, I want to display column c0, c3, and c4, and use c1 and c2 in
code behind.

The following Possible solution do not work:
dg.Column(3).Visible = false.

My analysis from the test: dg.Column(3).Visible = false is only working for
those columns which are defined in design by DataGrid Property Builder. If
you populate a table to the datagrid via binding programmatically, it does
not work, at least in my computer.

Any good solution for it?

Thanks

David

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.