Solved

Select a row in gridview

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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