Thursday, November 3, 2011

ASPxGridView Hyperlink NavigateUrl at Runtime

In the ASPxHyperLink.Init handler, you can use the ASPxGridView.GetDetailRowKeyValue method with ASPxHyperLink.NamingContainer property as a parameter, to get the main grid row key value.

[C#]

protected void ASPxHyperLink1_Init(object sender, EventArgs e) {
ASPxHyperLink myLink =(ASPxHyperLink)sender;
int key = Convert.ToInt32(ASPxGridView.GetDetailRowKeyValue(myLink.NamingContainer));
}


It would be better to use a binding-expression for the ASPxHyperLink.NavigateUrl property in the .ASPX file.



[ASPx]



<EmptyDataRow>
<dx:ASPxHyperLink ID="ASPxHyperLink1" runat="server" Text="ASPxHyperLink"
NavigateUrl="<%# ASPxGridView.GetDetailRowKeyValue(Container) %>" />
</EmptyDataRow>

No comments :

Post a Comment