前台代码:
<style type="text/css">
        css---------
        .HiddenColumn {
        display: none;
        }
    </style>

<asp:GridView ID="gd1" runat="server" AutoGenerateColumns="False" Width="212px" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal" OnRowDataBound="gd1_RowDataBound" OnSelectedIndexChanging="gd1_SelectedIndexChanging">
                                <Columns>
                                    <asp:BoundField HeaderText="序号" DataField="ID">
                                        <ItemStyle Width="60px" Font-Size="8pt"/>
                                        <HeaderStyle Font-Size="10pt" />
                                    </asp:BoundField>
                                   
                                    <asp:BoundField HeaderText="标题" DataField="ArticleName">
                                        <ItemStyle Width="158px" Font-Size="8pt" />
                                        <HeaderStyle Font-Size="10pt" />
                                    </asp:BoundField>
                                   
                                    <asp:BoundField HeaderText="位置" DataField="FileName">
                                        <ItemStyle Width="60px" Font-Size="8pt"/>
                                        <HeaderStyle Font-Size="10pt" />
                                    </asp:BoundField>
                                  
                                    <asp:CommandField   >
                                    <HeaderStyle CssClass="HiddenColumn" />
                                    <ItemStyle CssClass="HiddenColumn" />
                                    </asp:CommandField>
                                </Columns>
                                <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                                <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                                <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                                <AlternatingRowStyle BackColor="#F7F7F7" />
                            </asp:GridView>

后台代码:

/// <summary>
        /// 选择行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gd1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["OnClick"] = ClientScript.GetPostBackEventReference(e.Row.Parent.Parent, "Select$" + e.Row.RowIndex);
                e.Row.Attributes.Add("onMouseOver","t=this.style.backgroundColor;this.style.backgroundColor='#ebebce'");
                e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=t");
                e.Row.Attributes.CssStyle.Add("cursor", "hand");
            }
        }

这就是最简单的Gridview点击行,当点击GridView中某一行的时候,该行颜色会与其他行不同,便与区分..