Solved

Select a row in gridview

Posted on 2008-10-21
1
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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