views:

20

answers:

2

Iam displaying the days of a month in a grid. If the first day of the month starts with Wednesday then I need to gray out the cells of Monday and Tuesday for the first week. Is it possible to change the color of particular cell in a gridview? Iam not using rowdatabound Is there any alternative apart from rowdatabound??? pls help... thanx in advance :)

A: 

Unless there's an explicit reason why you don't want to use the RowDataBound event, I would say go ahead and use that.

If you absolutely don't want to use it; jQuery could probably do what you're looking for.

Jim B
A: 

See if below code helps you out: It is based on a template field with a label inside.

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

   If e.Row.RowType = DataControlRowType.DataRow Then
      Dim lbl As Label = CType(e.Row.FindControl("lblMonth"), Label)
        If DataBinder.Eval(e.Row.DataItem, "weekStart") == "Wednesday" Then
          lbl.ForeColor = Drawing.Color.Gray   
        End If
   End If
End Sub
lucene user