conditional formatting of text in a gridview

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I was looking to format the text of certain values in my gridview, but I have
a question first:

1) If I don't use an ObjectDataSource - but instead manually populate the
gridview - does it invalidate the RowDataBound event?

The reason I ask - is that even though I can see the values in this
gridview, it seems as though I am asking for them too early

Here's my RowDataBound event :

Protected Sub gvBP_Detail_AM_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs)

If e.Row.RowType = DataControlRowType.DataRow Then

Dim strSBP As String = e.Row.Cells(0).Text
Dim strDBP As String = e.Row.Cells(1).Text


Dim iSBP, iDBP, iSBPTarget, iDBPTarget As Integer


iSBP = Int32.Parse(strSBP)
iDBP = Int32.Parse(strDBP)
iSBPTarget = Int32.Parse(Me.txtSBP_Target.Text)
iDBPTarget = Int32.Parse(Me.txtDBP_Target.Text)


If iSBP > iSBPTarget Then e.Row.Cells(0).ForeColor =
Drawing.Color.Red
If iDBP > iDBPTarget Then e.Row.Cells(1).ForeColor =
Drawing.Color.Red

End If

End Sub

but, right off the bat, it doesn't see any value in e.row.cells(0).text -
which I can plainly see has the text "120" --- any idea why?
.



Relevant Pages

  • RE: DataGridView with databound combobox
    ... "'cboActivityTime' has a SelectedValue which is invalid because it does not ... My ObjectDatasource ... In the GridView RowEditing Event I can easily get hold of the Literal ... Dim row As GridViewRow ...
    (microsoft.public.dotnet.framework.aspnet)
  • .NET 2.0 Delete using GridView and ObjectDataSource
    ... connection) ... Dim list As New Generic.List ... the GridView has no DataKeyNames attribute set. ... DataObjectTypeName property in ObjectDataSource 'ObjectDataSource1'. ...
    (microsoft.public.dotnet.languages.vb)
  • Exporting to Excel directly from ObjectDataSource?
    ... I have a gridview with an objectdatasource. ... Dim tw As New IO.StringWriter ... Dim frm As HtmlForm = New HtmlForm ... I dislike that I have to pull from the Gridview at all. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Dynamically added user control
    ... I am dynamically adding a user control to each row in a gridview. ... ObjectDataSource) ... Dim pl As PlaceHolder = CType, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: dynamically building template columns
    ... getting added to the gridview, and my gridview gets pushed to the right. ... SortExpression before adding it to the gridview's Columns collection. ... Dim bfield As New BoundField ... // apply custom formatting to data cells ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)