Rewrite the hyperlink in gridview in the .aspx file as follows:
<asp:HyperLink ID="lnkConsumerID" runat="server" Text='<%# Eval("ConsumerID")%>' />
Then, in the image code, create a RowDataBound event handler:
protected void grdConsumers_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) return; var hlnkhlnk = (HyperLink)e.Row.FindControl("lnkConsumerID"); if (hlnkhlnk != null) { hlnkhlnk.NavigateUrl = "Vendor.aspx" + "?Consumer ID=" + hlnkhlnk.Text; } }
Hope this helps.
source share