Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional formatting in GridView

Status
Not open for further replies.

ZmrAbdulla

Technical User
Apr 22, 2003
4,364
AE
In Datagrid I have a simple procedure to bold entire row like below.
Code:
    Protected Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
        
        If (e.Item.Cells(6).Text = "Yes") Then
            e.Item.Cells(0).Font.Bold = True
            e.Item.Cells(1).Font.Bold = True
            e.Item.Cells(2).Font.Bold = True
            e.Item.Cells(3).Font.Bold = True
            e.Item.Cells(4).Font.Bold = True
            e.Item.Cells(5).Font.Bold = True
        End If
    End Sub
Cell(6) is a hidden. This is working fine.

How can I do it in GridView?


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
You could do the same thing by using the RowDataBound event and then using the e.Row.Cells method to reference each Cell. However, I'd set the e.Row.CSSClass to a class in your CSS file so that it's easier to maintain.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
No it is not working on RowDatabound Event, I tested prior to post.

I am not using any css

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Paste your code for the GridView and it's code behind as my test seems to work fine.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
It is working on "GridView1_RowCreated", GridView1_ItemDataBound", "GridView1_RowDataBound events. But the cell should be kept visible.That I don't prefer.

It was not working until I recreated the events.

For unknown reason the code inserted by the system was
Code:
 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
changed to
Code:
    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
when recreated.
I feel dumb...

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Did a work around..
changed data "Yes" to "*" then keeping the cell visible, headertext="" and font size to smallest. So that the * will not be visible to the user.

It is fine for now.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top