473,473 Members | 1,607 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PreRender checking value in textbox before making gridiview itemvisible

jc
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?
Dec 11 '07 #1
3 8830
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" <jo**@webdos.comwrote in message
news:b3**********************************@f3g2000h sg.googlegroups.com...
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?

Dec 12 '07 #2
jc
would anybody have an example of how I can loop through the grid and
change visibility of items after it's been built?
Dec 12 '07 #3
On Dec 12, 6:55 am, jc <j...@webdos.comwrote:
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;
}
}
Dec 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Wang | last post by:
I need change HeaderText of DataGrid in PreRender(). But it seems doesn't work. The code example like this: Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)...
7
by: wardy | last post by:
Hi, I'm hoping someone can lend me a hand....I've got a .NET Web app running on Windows 2000 IIS 5.0 linking to a SQL Server 2000 database. When the database is located on the same server as the...
3
by: Francois | last post by:
Hi, First of all sorry for the long post but I believe it is quite an interesting as well as advanced and complex problem. I have a problem with the checkbox control I have in my repeater. I...
2
by: Paul C. | last post by:
Hi folks. I have a WebControl TextBox which I would like to force to select all it's text during PreRender. My problem is that I don't know how to do this. I already have a reference to the...
9
by: D. Shane Fowlkes | last post by:
(ASP.NET 2 / VB) Question - How can I write a If statement to see if a control (textbox) actually exists on a page? Upon page_load, a certain control may or may not be visible on the page so I...
1
by: Mariella Bakker | last post by:
Hi All, In an ASP.NET project I am trying to improve performance. As it is now there seems to be a huge bottleneck between the end of the Page.PreRender event and the beginning of the...
0
by: mutlyp | last post by:
I have a PreRender event to set the width of my textbox when the Edit button is pressed on my grid here is the code: Private Sub grdPBC_PreRender(ByVal sender As Object, ByVal e As...
1
by: wildman | last post by:
In the Page_load my code check to see if session variable is set, if it is, it calls some subroutines that loads some grids and binds them. In my prerender, when the grids row is in update mode,...
2
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
i'm not sure how the preRender event gets handled. if i have a function: protected void tbPasswordPreRender(object sender, EventArgs e) { tbPswd1.Attributes = tbPswd1.Text; tbPswd2.Attributes...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.