1

我在 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)";
     }
  }

但是,我希望用户能够看到选择了哪一行并因此显示图像..(所以我希望行保持突出显示)。and then when another row is selected, i want that row to go back to normal and the newly selected one to be highlighted.

如果没有回发,我怎么能做到这一点?

4

1 回答 1

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;
        }
    }

可以帮到你!!

于 2012-05-05T10:34:52.553 回答