REDIRECT TO SPECIFIC PAGE WHEN A GRIDVIEW BUTTONFIELD IS CLICKED

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
 1376  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. Sumit Kesarwani

    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>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!