using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ProjectList : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { DataKey key; key = GridView1.DataKeys[GridView1.SelectedIndex]; int ProjectID = (int)key.Value; Response.Redirect("ProjectDetails.aspx?ProjectID=" + ProjectID); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.DataItemIndex == -1) return; string onmouseoverStyle = "this.style.cursor='hand';this.style.backgroundColor='Gainsboro'"; string onmouseoutStyle = "this.style.backgroundColor='#@BackColor'"; string rowBackColor = GridView1.RowStyle.BackColor.Name; string altBackColor = GridView1.AlternatingRowStyle.BackColor.Name; if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState == DataControlRowState.Alternate) { if (altBackColor.IndexOf("ff") == 0) { rowBackColor = "#" + altBackColor.Remove(0, 2); } else { rowBackColor = altBackColor; } } else { if (rowBackColor.IndexOf("ff") == 0) { rowBackColor = "#" + rowBackColor.Remove(0, 2); } } e.Row.Attributes.Add("onmouseover", onmouseoverStyle); e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("#@BackColor", rowBackColor)); } e.Row.Attributes.Add("onclick", this.GetPostBackClientEvent(GridView1, "Select$" + e.Row.RowIndex.ToString())); } }