Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Select a row in gridview

Posted on 2008-10-21
1
Medium Priority
?
237 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 2000 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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 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