Question about the ASP GridView control formatting

wings9697

Member
Joined
Aug 27, 2007
Messages
23
Location
Washington, DC
Programming Experience
10+
Hi. I have built an web page app using .NET 2.0 that goes out and collects information on the selected person in one table, and a picture of that person from another table, and returns both to a web page. The desired person is selected from a GridView control that contains a subset of the information to aid in selection.

I used the GridView control instead of the DataGridView control because it gave me a predefined SELECT button as a point of reference to fire off events from as well as to make it clear for my users to know how to select a record.

Now, a request has been made for the ability to identify particular records in that GridView based on results from a query before the GridView is populated and to inform the users about that condition via the formating of the indiviual line in the GridView control. It can be done in the DataGridView control, but I haven't seen any way to do it for the GridView control.

My question is, is there any way that a line in a GridView control can be formatted, outside of the SELECT event?

Thanks in advance....
 
Since I don't see the response I made to your previous post (?) I'll elaborate on JohnH's suggestion of using the RowDataBound event.

Check to see that you're working with a DataRow and then check the contents on the cell.

VB.NET:
        If e.Row.RowType = DataControlRowType.DataRow Then
            Select Case e.Row.Cells(0).Text
                Case "AWDW", "Sex Offender", "Door to Door Salesman"
                    e.Row.Font.Bold = True
                    e.Row.BackColor = Drawing.Color.Red
            End Select
        End If
 
Back
Top