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

Home Posts Topics Members FAQ

GridView RowDataBound Event Issues

Hello everyone, I'm in a bind, and I hope somebody can point me in the
right direction.

I have a gridview that is bound when it is not a postback. When the
grid is bound, I remove the contents of a cell based on criteria

e.g.
Protected Sub gvOffSiteHoursRequests_RowDataBound(ByVal sender As
Object, _
ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles gvOffSiteHoursRequests.RowDataBound
if (str = "example) then
e.Row.Cells(0).Controls.Clear()
end if
This works great EXCEPT when another control on the same page has a
postback, the controls are un-cleared, the grid is possibly reloaded
from viewstate and does not fire my RowDataBound event because the
event was not called. This could be remedied by binding the grid every
time there is a postback, but this would mess up the editing etc.

I hope that makes sense. Please let me know if you have any ideas.

Thank you and have a great day,
Ryan

Sep 2 '06 #1
3 2636
I got around it by doing this:

if (Page.IsPostBack And
Request.Form("__EVENTTARGET").IndexOf("gvOffSiteHo ursRequests") = -1)
then

LoadDate

Seems very dirty, if anyone has a better solution, I would appreciate
it!

Thanks,
Ryan
ry*********@gmail.com wrote:
Hello everyone, I'm in a bind, and I hope somebody can point me in the
right direction.

I have a gridview that is bound when it is not a postback. When the
grid is bound, I remove the contents of a cell based on criteria

e.g.
Protected Sub gvOffSiteHoursRequests_RowDataBound(ByVal sender As
Object, _
ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles gvOffSiteHoursRequests.RowDataBound
if (str = "example) then
e.Row.Cells(0).Controls.Clear()
end if
This works great EXCEPT when another control on the same page has a
postback, the controls are un-cleared, the grid is possibly reloaded
from viewstate and does not fire my RowDataBound event because the
event was not called. This could be remedied by binding the grid every
time there is a postback, but this would mess up the editing etc.

I hope that makes sense. Please let me know if you have any ideas.

Thank you and have a great day,
Ryan
Sep 2 '06 #2
RowCreated runs also on hwne grid is restored from viewstate (it also runs
just before RowdataBound)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ry*********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
>I got around it by doing this:

if (Page.IsPostBack And
Request.Form("__EVENTTARGET").IndexOf("gvOffSiteHo ursRequests") = -1)
then

LoadDate

Seems very dirty, if anyone has a better solution, I would appreciate
it!

Thanks,
Ryan
ry*********@gmail.com wrote:
>Hello everyone, I'm in a bind, and I hope somebody can point me in the
right direction.

I have a gridview that is bound when it is not a postback. When the
grid is bound, I remove the contents of a cell based on criteria

e.g.
Protected Sub gvOffSiteHoursRequests_RowDataBound(ByVal sender As
Object, _
ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles gvOffSiteHoursRequests.RowDataBound
if (str = "example) then
e.Row.Cells(0).Controls.Clear()
end if
This works great EXCEPT when another control on the same page has a
postback, the controls are un-cleared, the grid is possibly reloaded
from viewstate and does not fire my RowDataBound event because the
event was not called. This could be remedied by binding the grid every
time there is a postback, but this would mess up the editing etc.

I hope that makes sense. Please let me know if you have any ideas.

Thank you and have a great day,
Ryan

Sep 3 '06 #3
Hello Teemu, great idea! That will be much better then what I was
using. All these new events to learn about. Thank you very much. Have a
great weekend,
Ryan

Teemu Keiski wrote:
RowCreated runs also on hwne grid is restored from viewstate (it also runs
just before RowdataBound)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ry*********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
I got around it by doing this:

if (Page.IsPostBack And
Request.Form("__EVENTTARGET").IndexOf("gvOffSiteHo ursRequests") = -1)
then

LoadDate

Seems very dirty, if anyone has a better solution, I would appreciate
it!

Thanks,
Ryan
ry*********@gmail.com wrote:
Hello everyone, I'm in a bind, and I hope somebody can point me in the
right direction.

I have a gridview that is bound when it is not a postback. When the
grid is bound, I remove the contents of a cell based on criteria

e.g.
Protected Sub gvOffSiteHoursRequests_RowDataBound(ByVal sender As
Object, _
ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) _
Handles gvOffSiteHoursRequests.RowDataBound
if (str = "example) then
e.Row.Cells(0).Controls.Clear()
end if
This works great EXCEPT when another control on the same page has a
postback, the controls are un-cleared, the grid is possibly reloaded
from viewstate and does not fire my RowDataBound event because the
event was not called. This could be remedied by binding the grid every
time there is a postback, but this would mess up the editing etc.

I hope that makes sense. Please let me know if you have any ideas.

Thank you and have a great day,
Ryan
Sep 3 '06 #4

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

Similar topics

1
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an...
5
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
6
by: AG | last post by:
I have a gridview with a template column containing an imagebutton to delete the row. Under some condition I don't want the row to be deleted, so would like to remove the button. In the...
2
by: Tim | last post by:
I'm using a GridView with its DataSource property set to a DataTable. During the RowDataBound event, the first row of the DataTable is reported as a DataControlRowType.Header instead of...
3
by: David C | last post by:
I have a GridView and when the SelectedIndexChange occurs I want to put the value of a BoundField into a TextBox (txtPropertyID) on the page. Below is the code I am using but it is not getting the...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
13
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
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 ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.