top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to change colour of the datagridview cell at runtime?

+2 votes
468 views

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
        Next
    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 vb.net?

+2 votes

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

<customErrors
   mode="RemoteOnly" 
   defaultRedirect="~/Error.aspx" />

This is not working.

...