1

asp.netにグリッドビューがあり、クリックされるたびにプレビュー画像が更新されます。これはポストバックなしで機能し、私は次のようにします。

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

ただし、どの行が選択されているかをユーザーが確認できるようにして、画像を表示できるようにする必要があります(したがって、行を強調表示したままにします)。次に、別の行を選択すると、その行を通常の行に戻し、新しく選択した行を強調表示します。

ポストバックなしでこれを行うにはどうすればよいですか?

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 に答える