1

I have a gridview and added a column "Hyperlink" to all records by enabling autogeneratefields. When this gridview is loaded and when I click the hyperlink across any record I want to redirect to some other page with entire record passed as query string to that page? can anybody help me on this?

1 Answer 1

2

These links should clarify how to do it:

How to pass variables thru a DataGrid hyperlink column

How To: Use a HyperLink control inside a GridView

Sample code (Look at the NavigateUrl property of HyperLink):

<asp:GridView ID="urlGrid" runat="server" AutoGenerateColumns="False">
   <Columns>
      <asp:TemplateField>
         <ItemTemplate>

   <asp:HyperLink ID="HyperLink1"
                  runat="server"
                  NavigateUrl='<%# "RedirectPage.aspx?xxxx=" &
                  DataBinder.Eval(Container, "DataItem.xxxx") &
                 "&yyyy=" & DataBinder.Eval(Container, "DataItem.yyyy")%>'
                  Text="Go!">
   </asp:HyperLink>

     </ItemTemplate>
  </asp:TemplateField>
  <asp:BoundField DataField="SiteName" HeaderText="Site Name" />
   </Columns>
</asp:GridView>
Sign up to request clarification or add additional context in comments.

2 Comments

Am not passing any variables to hyperlink column.The thing is that when I click the link across any record i have to be redirected to some other page with the record as querysting. supposing you have a gridview of the following format, Name Address xxxx yyyyy BID aaaa bbbbb BID when I click the BID link at the first record,it should be directed to next page with xxxx,yyyy as querystring. thanks
The pages I linked above show you how to do just that... You can choose which row fields you want to be passed in the query string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.