Click here to Skip to main content
15,922,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview generated from code behind. I have a link column. when i click to link column i want redirect to another page.

Thanks,
MB.
Posted
Updated 11-Sep-12 1:32am
v2

There are two ways you can make it work. You can create either HyperLinkField or add a Hyperlink in <asp:templatefield >
Have a look:
<Columns>
            <asp:HyperLinkField DataTextField="LeadID" DataNavigateUrlFields="LeadID" DataNavigateUrlFormatString="LeadInformation.aspx?LeadID={0}" Text="Lead ID" />
            <asp:BoundField DataField="DateTime" HeaderText="Date Updated" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Bind("LeadID") + Request.QueryString("type") %>'Text=""></asp:HyperLink>
                </ItemTemplate>
             </asp:TemplateField>
</Columns>>

Refer:
link button using in gridview another page redirect[^]
How to add dynamic hyperlink in Grid View according to certain condition[^]
 
Share this answer
 
Comments
__TR__ 11-Sep-12 7:40am    
5ed!
Prasad_Kulkarni 11-Sep-12 7:42am    
Thank you Tejas!
Hello dude try this code


XML
<asp:TemplateField >
                  <ItemTemplate>

                  <asp:HyperLink ID="btnredirect" runat="server" Text="Redirect" NavigateUrl="redirectonPagename.aspx"  />
               </ItemTemplate>
                  
              </asp:TemplateField>
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900