Solved

Select a row in gridview

Posted on 2008-10-21
1
222 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

20 Experts available now in Live!

Get 1:1 Help Now