469,602 Members | 1,818 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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 2506
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Giovanni | last post: by
5 posts views Thread by sutphinwb | last post: by
6 posts views Thread by Kevin Attard | last post: by
6 posts views Thread by AG | last post: by
3 posts views Thread by David C | last post: by
11 posts views Thread by SAL | last post: by
13 posts views Thread by SAL | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.