Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting NavigateURL value using data binding.

Posted on 2007-04-08
4
Medium Priority
?
3,107 Views
Last Modified: 2012-08-14
I am trying to get the value of a database table column and use it to navigate to a different web page.  I am using the following syntax which works.  It redirects to the new page and passes the value of "refurl" but it does not pass the value of "Story_ID".  

<asp:HyperLink id="show_story" runat="server"
NavigateUrl='~/view_story.aspx?refurl=default.aspx&story=<%# DataBinder.Eval(Container.DataItem, "Story_ID") %>

On its own, <%# DataBinder.Eval(Container.DataItem, "Story_ID") %> returns the value stored in Story_ID.

I am trying to use this in a repeater control on a asp.net web page.
0
Comment
Question by:Mike_Stevens
[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
  • 2
4 Comments
 
LVL 15

Expert Comment

by:igor_alpha
ID: 18873672
Hi Mike_Stevens,
In one of my projects I have same syntax of generating URL in repeater and everything work well.
Probably, you forgot to bind data to repeater?

Syntax must be such following:
Repeater1.DataSource = values;
Repeater1.DataBind();

If you use SqlDataSource or ObjectDataSource check out that it filling with values.
0
 
LVL 3

Accepted Solution

by:
viveksg earned 2000 total points
ID: 18874530
Try this mate.

<asp:HyperLink ID="show_story" Runat="server" NavigateUrl='<%# "~/view_story.aspx?refurl=default.aspx&story=" + DataBinder.Eval(Container.DataItem, "Story_ID")%>'>Click Here</asp:HyperLink>
0
 

Author Comment

by:Mike_Stevens
ID: 18874968
Your code returns  "Conversion from string "~/view_story.aspx?refurl=default" to type 'Double' is not valid."

The "story ID" value is a numeric value.

0
 

Author Comment

by:Mike_Stevens
ID: 18874976
i converted the story ID value to a string and it works fine.   Thanks for the help

DataBinder.Eval(Container.DataItem, "Story_ID").tostring
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

670 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