Rob,
you could to this in RowCreated event of the GridView, if you have a button
called btnButton in the column index 4, the code would be like this:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button btnButton =
(Button)e.Row.Cells[4].FindControl("btnButton");
btnButton.Attributes.Add("onmouseover",
"this.className='actionH'");
btnButton.Attributes.Add("onmouseout",
"this.className='actionN'");
}
}
also, you could do this after calling DataBind() method of the GridView,
this code would be almost the same...
foreach (GridViewRow row in GridView1.Rows)
{
Button btnButton =
(Button)row.Cells[4].FindControl("btnButton");
btnButton.Attributes.Add("onmouseover",
"this.className='actionH'");
btnButton.Attributes.Add("onmouseout",
"this.className='actionN'");
}
Bruno
"Rob Roberts" <ro************@AndThisToo.pcisys.net> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Is there any way to add attributes to GridView ButtonFields? I'm looking
for a way to add event handlers to ButtonFields. With regular ASP.NET
buttons, I can add event handlers by using the Attributes collection, like
this:
MyButton.Attributes.Add("onmouseover", "this.className='actionH'");
MyButton.Attributes.Add("onmouseout", "this.className='actionN'");
But the GridView ButtonField doesn't seem to have an Attributes property.
Is there any way that event handlers can be added to ButtonFields?
Thanks in advance,
--Rob Roberts