Hi Art,
You want to catch the ItemCreated event of the datagrid. That's when a row is
being built. At that time, you can look into the row for the control you're
after and start changing its attributes. The following code looks for a button
and adds JavaScript to it:
Private Sub DataGrid1_ItemCreated _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemCreated
Dim btnAdd As New Button
If e.Item.ItemType = ListItemType.AlternatingItem Or _
e.Item.ItemType = ListItemType.Item Then
btnAdd = e.Item.FindControl("Button1")
btnAdd.Attributes.Add("onclick", "alert(this.id)")
End If
End Sub
Ken
--
Help stop SWEN in the newsgroups - Get the W32.Swen.A@mm Removal Tool:
http://securityresponse.symantec.com/avcenter/venc/data/[email protected]
If I have a datagrid cell that contain say a webform DropDownList x
how do I add a client's "onclick" attribute to it?
I can't just say x.Attributes.Add("onclick", "alert(this.value)");
because the datagrid is not bind yet.