Check after RowDataBound

D

David C

I have 3 gridviews on an aspx page and I want to set some values after all 3
have been databound. Where is the best place to do that? I have tried
doing it in the footer of the 3rd gridview but it is not working. Thanks.

David
 
D

David C

Below is the code of the RowDataBound for the 3 GridViews.

Protected Sub gvShop1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim strSize As String = _
Convert.ToString(DataBinder.Eval(e.Row.DataItem,
"JobSize"))
If strSize = "H" Then
intHeavyCount = intHeavyCount + 1
Else
If strSize = "S" Then
intSmallCount = intSmallCount + 1
End If
End If
intCount1 = intCount1 + 1
If intTarget1 >= intCount1 Then
' color the background of the row green
e.Row.BackColor = Drawing.Color.Green
Else
e.Row.BackColor = Drawing.Color.Red
End If
Else
If e.Row.RowType = DataControlRowType.Footer Then
txtHeavy1.Text = intHeavyCount.ToString
End If
End If
End Sub

Protected Sub gvShop5_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
intCount5 = intCount5 + 1
If intTarget5 >= intCount5 Then
' color the background of the row green
e.Row.BackColor = Drawing.Color.Green
Else
e.Row.BackColor = Drawing.Color.Red
End If
End If
End Sub

Protected Sub gvShop7_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
intCount7 = intCount7 + 1
If intTarget7 >= intCount7 Then
' color the background of the row green
e.Row.BackColor = Drawing.Color.Green
Else
e.Row.BackColor = Drawing.Color.Red
End If
Else
If e.Row.RowType = DataControlRowType.Footer Then
If intCount7 = 0 Then
'no jobs in waiting for flow
txtActual7.ForeColor = Drawing.Color.Green
If intCount5 = 0 Then
'no jobs in waiting for heavy so make waiting for rp
red
txtActual1.ForeColor = Drawing.Color.Red
txtActual5.ForeColor = Drawing.Color.Green
Else
'all jobs in waiting for rp are not heavy
If intSmallCount = 0 Then
txtActual1.ForeColor = Drawing.Color.Green
txtActual5.ForeColor = Drawing.Color.Red
Else
txtActual1.ForeColor = Drawing.Color.Red
txtActual5.ForeColor = Drawing.Color.Green
End If
End If
Else
'Jobs in waiting for flow
If intCount7 > intTarget7 Then
'waiting for flow is over target
txtActual7.ForeColor = Drawing.Color.Red
txtActual1.ForeColor = Drawing.Color.Green
txtActual5.ForeColor = Drawing.Color.Green
Else
If intHeavyCount < intCount1 Then
'all jobs in waiting for rp are not heavy
txtActual1.ForeColor = Drawing.Color.Red
txtActual5.ForeColor = Drawing.Color.Green
Else
'all jobs in waiting for rp are heavy
txtActual5.ForeColor = Drawing.Color.Red
txtActual1.ForeColor = Drawing.Color.Green
End If
End If
End If
End If
End If
End Sub

The GridView gvShop7 is where I am trying to determine all counts, etc. from
gvShop1 and gvShop5 GridViews. I am assuming that gvShop7 RowDataBound
event runs after the gvShop1 and the gvShop5 RowDataBound events. The data
for all 3 changes frequently so I am doing Postbacks every 2 minutes. I am
finding that the colors of txtActual1 and txtActual5 are not always correct,
so I put a message in the gvShop7 RowDataBound event and it is not showing
and the colors are not changing. Does this help? Thanks.

David
 
P

Paul Shapiro

You are "assuming that gvShop7 RowDataBound event runs after the gvShop1 and
the gvShop5 RowDataBound events". Unless you're controlling the databinding
order in your own code, I don't think that's a valid assumption. If the
gvShop7 display depends on totaling data from the other queries, it might be
better to use a query for gvShop7 that does the aggregation directly. That
would make gvShop7 independent of the other gridviews.
 
D

David C

Thank you, I will try that.

David
Paul Shapiro said:
You are "assuming that gvShop7 RowDataBound event runs after the gvShop1
and the gvShop5 RowDataBound events". Unless you're controlling the
databinding order in your own code, I don't think that's a valid
assumption. If the gvShop7 display depends on totaling data from the other
queries, it might be better to use a query for gvShop7 that does the
aggregation directly. That would make gvShop7 independent of the other
gridviews.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top