Re: Get DataKey on RowDataBound
- From: "MasterChief" <constants@xxxxxxxxxxx>
- Date: 15 Feb 2006 15:03:45 -0800
I can get the DataKey using the RowCommand Event but I want to be able
to put the OnClick attribute into the Row and have it alert the KeyID.
When I try to get the value of KeyID that I got in RowCommand it comes
back with a null value. The only way I can find to add an attribute to
a row is during the RowDataBound Event.
Public Class _MasterTestBed
Inherits System.Web.UI.Page
Dim KeyID As String
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
GridView1.RowCommand
KeyID = GridView1.DataKeys(e.CommandArgument).Value.ToString
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Attributes.Add("onMouseOver",
"this.style.backgroundColor='lightgrey'")
e.Row.Attributes.Add("onMouseOut",
"this.style.backgroundColor='Transparent'")
e.Row.Attributes.Add("onClick", "alert('" + KeyID + "')'")
End If
End Sub
End Class
.
- References:
- Get DataKey on RowDataBound
- From: MasterChief
- Re: Get DataKey on RowDataBound
- From: tdavisjr
- Re: Get DataKey on RowDataBound
- From: tdavisjr
- Get DataKey on RowDataBound
- Prev by Date: Re: Really slow, painfullu slow asp.net web app
- Next by Date: Re: linking to ms access database using odbc adapters
- Previous by thread: Re: Get DataKey on RowDataBound
- Next by thread: linking to ms access database using odbc adapters
- Index(es):
Relevant Pages
|