Home > Forum > ASP.NET > How to change the url on grid view linkbutton click in asp.net?

How to change the url on grid view linkbutton click in asp.net?

by Thamil   on Oct 14, 2014   Category: ASP.NET  |  Views: 2060    |  Points: 5   |  Gold 
  Reply
Hi,

Here is the scenario.

I logged in from the admin
my url will be like http://localhost:51340/csi/admin/abcd.aspx
but the file abcd.aspx is not in admin folder.

i create a grid view and which create a link button like this
http://localhost:51340/csi/admin/TeamDetails.aspx?TeamId=67

so i want this as
http://localhost:51340/csi/TeamDetails.aspx?TeamId=67

so that the code worked if that click on the link.

Here is the link code.


<div>
<a href="">
<asp:LinkButton ID="lnkSecondTeam" runat="server" CausesValidation="false"
PostBackUrl='<%# Eval("Team2_Id","TeamDetails.aspx?TeamId={0}") %>'Text='<%#Eval("Team2") %>'></asp:LinkButton>
</a>v/s <a href="">
<asp:LinkButton ID="lnkFirstTeam" runat="server" CausesValidation="false"
PostBackUrl='<%# Eval("Team1_Id","TeamDetails.aspx?TeamId={0}") %>'Text='<%#Eval("Team1") %>'></asp:LinkButton>
</a>
</div>

Can this possible?
If yes then please let me how?
Thanks

Question posted on behalf of Rajesh kumar

Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :How to change the url on grid view linkbutton click in asp.net?   
by Thamil
on Oct 14 2014 4:47AM
Points : 10
Gold 
Hi Rajesh kumar,

It’s possible, follow the below code. I have added ../ prefix of TeamDetails.aspx
<div>
<a href="">
<asp:LinkButton ID="lnkSecondTeam" runat="server" CausesValidation="false"
PostBackUrl='<%# Eval("Team2_Id","../TeamDetails.aspx?TeamId={0}") %>'Text='<%#Eval("Team2") %>'></asp:LinkButton>
</a>v/s <a href="">
<asp:LinkButton ID="lnkFirstTeam" runat="server" CausesValidation="false"
PostBackUrl='<%# Eval("Team1_Id","../TeamDetails.aspx?TeamId={0}") %>'Text='<%#Eval("Team1") %>'></asp:LinkButton>
</a>
</div>


Let me know if you have any clarification on this.

Recent Post

Latest Posts