четверг, 22 сентября 2011 г.

js для ButtonField ButtonType="Image" в GridView

Спросили меня на днях, как добавить js для ButtonField ButtonType="Image", вроде мелоч а сразу и не сообразил, не долго лазия в google дал ответ))):
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
 if (e.Row.RowType == DataControlRowType.DataRow &&

  (e.Row.RowState ==

 DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate))
  {
  if (e.Row.Cells[columnGrid].Controls[0] is ImageButton)
   {
    ((ImageButton)e.Row.Cells[columnGrid].Controls[0]).Attributes.Add("onclick",
    "alert('123');");
   }
  }
}

Комментариев нет:

Отправить комментарий