Redirect to specific page when a gridview buttonfield is clicked

Total Post:154

Points:1086
 1670  View(s)
Ratings:
Rate this:

I have two fields in my gridview. One is a field with a date range and one of them is a buttonfield. I want to make it so that when a button is clicked, it will redirect them to a specific page with a formatted string similar to how it's done when a hyperlinkfield is clicked as such:

DataNavigateUrlFormatString="ProductInfo.aspx?ProductID={0}"

Is there a way I can do the same thing with a button?

  1. Post:378

    Points:2694
    Re: Redirect to specific page when a gridview buttonfield is clicked

    Hi Manoj, 


    Try using this type of column instead of a ButtonField:

    <Columns>
       <asp:HyperLinkField DataTextField="ProductName" HeaderText="Product Name"
         SortExpression="ProductName"      DataNavigateUrlFields="ProductID"      DataNavigateUrlFormatString="ProductInfo.aspx?ProductID={0}"/>
    </Columns>

      Modified On Apr-05-2018 05:51:15 AM

Answer