HighTechTalks DotNet Forums  

PreRender checking value in textbox before making gridiview itemvisible

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss PreRender checking value in textbox before making gridiview itemvisible in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
jc
 
Posts: n/a

Default PreRender checking value in textbox before making gridiview itemvisible - 12-11-2007 , 01:40 PM






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?

Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: PreRender checking value in textbox before making gridiview item visible - 12-12-2007 , 04:44 AM






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.

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


"jc" <jobs (AT) webdos (DOT) com> wrote

Quote:
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?



Reply With Quote
  #3  
Old   
jc
 
Posts: n/a

Default Re: PreRender checking value in textbox before making gridiview itemvisible - 12-12-2007 , 06:55 AM



would anybody have an example of how I can loop through the grid and
change visibility of items after it's been built?

Reply With Quote
  #4  
Old   
gnewsgroup
 
Posts: n/a

Default Re: PreRender checking value in textbox before making gridiview itemvisible - 12-12-2007 , 08:30 AM



On Dec 12, 6:55 am, jc <j... (AT) webdos (DOT) com> wrote:
Quote:
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;
}
}


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.