I have a Gridview that is correctly getting data from a database. I want to add an image in each row that when clicked, will link to another page and that link will have a parameter passed with it. If I was using a HyperLinkField, I would use the DataNavigateUrlFormatString attribut but it does not work when using the ButtonField. Am I missing something silly here? My code is below. Thank you.
<asp:Panel runat="server" ID="pnlresults" Visible="false">
<asp:SqlDataSource runat="server" ID="requestedDataSource"
CancelSelectOnNullParameter="false"
ConnectionString="<%$ ConnectionStrings:UnitySQLServerConnectionString %>"
SelectCommand="SELECT PriceListID, PriceListCode, PriceListName, isActive, StartDate, EndDate FROM [SQLQA].[dbo].[Price_Header]">
</asp:SqlDataSource>
<asp:GridView runat="server"
AllowSorting="true"
AutoGenerateColumns="false"
DataSourceID="requestedDataSource"
CssClass="searchOutput"
HeaderStyle-HorizontalAlign="Left"
RowStyle-HorizontalAlign="Left"
AlternatingRowStyle-HorizontalAlign="Left">
<Columns>
<asp:BoundField DataField="PriceListCode" HeaderText="Code" />
<asp:BoundField DataField="PriceListName" HeaderText="Name" />
<asp:BoundField DataField="isActive" HeaderText="Active" />
<asp:BoundField DataField="StartDate" HeaderText="Start Date" />
<asp:BoundField DataField="EndDate" HeaderText="End Date" />
<asp:ButtonField HeaderText="Copy" ImageUrl="../../Images/plus.gif" ButtonType="Image" CommandName="" />
<asp:HyperLinkField DataNavigateUrlFields="PriceListID" HeaderText="Copy"
DataNavigateUrlFormatString="~/?Order_No={0}"
Text="Copy" />
</Columns>
</asp:GridView>
</asp:Panel>
The ButtonField doesn't have a DataNavigateUrlFormatString attribute. So no, it will not work.
If you want to add an image to the hyperlink, you can do it something like this: