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 / December 2007

Tip: Looking for answers? Try searching our database.

Setting Visibility on Gridview items after they are created?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jc - 11 Dec 2007 22:28 GMT
I have a situation where I need to condition gridview item visibilty
after they've been created and after a textbox on page has a value.
What's the best way to do this in VB.NET? Any code sample?

I would imagine i have to loop through the control to do this.

Seems like it might be messy.
Michael Nemtsev - 11 Dec 2007 23:00 GMT
I suppose the looping of control hierarchy is the single way,
because your items are inside other control and u need find them somehow

Signature

WBR,  Michael  Nemtsev [.NET/C# MVP].  
Blog: http://spaces.live.com/laflour

> I have a situation where I need to condition gridview item visibilty
> after they've been created and after a textbox on page has a value.
[quoted text clipped - 3 lines]
>
> Seems like it might be messy.
Eliyahu Goldin - 12 Dec 2007 09:19 GMT
Do it in the PreRender event.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

>I suppose the looping of control hierarchy is the single way,
> because your items are inside other control and u need find them somehow
[quoted text clipped - 6 lines]
>>
>> Seems like it might be messy.
jc - 12 Dec 2007 11:57 GMT
Does anybody have any vb.net example of looping through the gridview
and setting visibility of an item after it's been built?
gnewsgroup - 12 Dec 2007 13:38 GMT
> Does anybody have any vb.net example of looping through the gridview
> and setting visibility of an item after it's been built?

I think you can do something like this (in C#, I am not good at VB):

foreach (GridViewRow gvr in MyGridView.Rows)
{
        // If you know the column index, you can do:
        gvr.Cells[2].Visible = false;
        // Or if you want to make some control in that cell
invisible:
        TextBox myTextBox = (TextBox)gvr.FindControls("myTextBox");
        myTextBox.Visible = false;
}

The code hasn't been tested, but you get the idea.
gnewsgroup - 12 Dec 2007 13:56 GMT
> Does anybody have any vb.net example of looping through the gridview
> and setting visibility of an item after it's been built?

It's been answered here:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_t
hread/thread/2e26393b256aff43/c923a8cca6231531?hl=en#c923a8cca6231531


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.