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.

PreRender checking value in textbox before making gridiview item     visible

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jc - 11 Dec 2007 18:40 GMT
Hello.

I have a gridview column item that i want to not make visible if the
bound data in that cell is less than a value in a textbox.

However, I notice at the time my code checks a function that I call
from the visible property of the gridview itemtemplate, the textbox is
always blank.

I tried setting the textbox in the prerender, but I suspect the
gridview is built much earlier in another event.. like items created.

Whats the best way to attack this?

Also, and a question I can't believe I'm asking.. what's the preferred
way to store information in a codebehind variable so that's a
available across all subs, functions and events? For example, if I
want to have something in a variable I set in the prerender, how do I
make that available in Page load sub?
Eliyahu Goldin - 12 Dec 2007 09:44 GMT
PreRender is the right place for this. At this stage the grid has already
been fully built, which is your advantage rather than a disadvantage since
no-one will intervene in the final changes you are making there.

PreRender event fires after Load, so it won't help if you set something in
PreRender. Otherwise, if you just declare a field or a property in your page
class it will be visible by all other members.

Signature

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

> Hello.
>
[quoted text clipped - 15 lines]
> want to have something in a variable I set in the prerender, how do I
> make that available in Page load sub?
jc - 12 Dec 2007 11:55 GMT
would anybody have an example of how I can loop through the grid and
change visibility of items after it's been built?
gnewsgroup - 12 Dec 2007 13:30 GMT
> would anybody have an example of how I can loop through the grid and
> change visibility of items after it's been built?

Sounds like you can use a RowDataBound event handler like so (very
sketchy code, but you get the idea.)

 protected void MyGridView_RowDataBound(object s,
GridViewRowEventArgs e)
   {
       // Hide the header of the leftmost column.
       if (e.Row.RowType == DataControlRowType.Header)
       {
           e.Row.Cells[0].Visible = false;
       }

       // Hide the leftmost column of the data row.
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           e.Row.Cells[0].Visible = false;
       }
   }

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.