Solved

Select a row in gridview

Posted on 2008-10-21
1
226 Views
Last Modified: 2013-11-07
I have a hyperlink in my gridview that when a user clicks on it, he/she is directed to another page. It is working great. However, I want to be able to redirect the user to another webpage depending on what row he selects. For example: If the row he/she clicks on is an apartment, then I want to direct them to apartment.aspx. However, if the row is a house then I want to redirect to house.aspx.

I am sure I can simply have it refer to a column in my database with that info. However, I can't see where I am able to do that. I hope I am making sense on this.
0
Comment
Question by:smitty68521
1 Comment
 
LVL 6

Accepted Solution

by:
M3mph15 earned 500 total points
ID: 22773234
Hi,
What you can do is get the hyperlink to call a function that returns a string to define the NavigateUrl. E.g
 <asp:HyperLink ID="HyperLink1" runat="server" CssClass="hlStyle" NavigateUrl='<%# FormatUrl( Eval("[Column name]")) %>'>View</asp:HyperLink>  
'[Column name] will be whatever column in your database you are using to define the link. In your case wether its a apartment or house. So in the code behind we put this function:
Public Function FormatUrl(ByVal type As String) As String
        Select Case type
                      case "apartment"
                                   Return "Apartment.aspx"
                      case "house"
                                   Return "House.aspx"
End Function
 Hope this helps
-M3mph15
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now