Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

Make columns (fields) invisible dynamically?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
david - 20 Oct 2005 16:56 GMT
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
Phillip Williams - 21 Oct 2005 05:14 GMT
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/DataGridEventDelegates.aspx an experiment
in hiding/displaying columns with a dynamically created DataGrid.  

Signature

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

> I have posted my question before. It seems that I can not find the solution.
> The question:
[quoted text clipped - 18 lines]
>
> David
david - 21 Oct 2005 19:03 GMT
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

> Hi David,
>
[quoted text clipped - 25 lines]
> >
> > David
Phillip Williams - 21 Oct 2005 21:07 GMT
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/DataGrid_ChildControlsEvents.aspx

Signature

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

> 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.
[quoted text clipped - 35 lines]
> > >
> > > David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.