top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to change colour of the datagridview cell at runtime?

+2 votes

I want it to be changes as soon as I change the value in some other cell!

posted Jul 30, 2014 by Muskan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
Best answer
Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim quantity As Integer = Integer.Parse(e.Row.Cells(1).Text)

        For Each cell As TableCell In e.Row.Cells
            If quantity = 0 Then
                cell.BackColor = Color.Red
            End If
            If quantity > 0 AndAlso quantity <= 50 Then
                cell.BackColor = Color.Yellow
            End If
            If quantity > 50 AndAlso quantity <= 100 Then
                cell.BackColor = Color.Orange
            End If
    End If
End Sub
answer Nov 13, 2014 by Manikandan J
Similar Questions
+5 votes

How to change postion if a contrl at runtime in

+2 votes

If somke error occurs i want the system to redirect to some other page and not show he error message.

   defaultRedirect="~/Error.aspx" />

This is not working.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.