you can also do this with the help of java script.
i did that by using the following way to change the background color of
the datagrid row.
i added a javascript on the item createevent of grid
however i m using the following code to change the background color, you
can also try to change the fore color by changing the css class of TD
etc.
hope that helps
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
code
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim cn As New OleDb.OleDbConnection(connectionstring)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
BindGrid()
End If
End Sub
Private Sub BindGrid()
'code to bind grid
End Sub
Private Sub dgusers_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgusers.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.SelectedItem Then
e.Item.Attributes.Add("onMouseOver",
"this.style.backgroundColor='#0099cc';this.style.cursor='hand';")
e.Item.Attributes.Add("onMouseOut",
"this.style.backgroundColor='#f5f5f5';")
e.Item.Attributes.Add("onclick", "javascript:__doPostBack('"
& "dgusers:" & "ctrl" & e.Item.ItemIndex & ":ctrl0','')")
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
HTML
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<asp:datagrid id="dgusers" runat="server" Width="100%"
HorizontalAlign="Center" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4"
PageSize="2" AllowPaging="True"
AllowSorting="True">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399"
CssClass="tborder" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC"
BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns><asp:ButtonColumn Visible="False" Text="Select"
CommandName="Select"></asp:ButtonColumn>
</Columns>
<PagerStyle BorderWidth="2px" BorderStyle="Ridge"
HorizontalAlign="Center" ForeColor="#330099"
BackColor="#FFFFCC" CssClass="tborder" Mode="NumericPages"></PagerStyle>
</asp:datagrid>