Solved

Setting NavigateURL value using data binding.

Posted on 2007-04-08
4
3,105 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 500 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
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…
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…

617 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