我在asp.net中有一个gridview,它会在点击时更新预览图片。这没有回发工作,我这样做:
protected void GridView1_RowCreated(object sender,System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.ToolTip = "Click to select row";
e.Row.Attributes["onclick"] = "RetrievePicture(" + GVmail.DataKeys[e.Row.RowIndex].Value.ToString() + ",this)";
}
}
但是,我希望用户能够看到选择了哪一行,从而显示图像..(所以我想要排列以保持高亮显示)。然后当选择另一行时,我希望该行恢复正常,并重新选择一行。
如果没有回发,我怎么能这样做?
答案 0 :(得分:0)
看到它
for (int i = 0; i < gridview.Rows.Count; i++)
{
GridViewRow row;
row = gridview.Rows[i];
if (row.Cells[1].Text.Equals("ABSENT"))
{
row.BackColor = System.Drawing.Color.IndianRed;
row.ForeColor = System.Drawing.Color.White;
row.Font.Bold = true;
}
}
migth帮助你!!