Solved

Setting NavigateURL value using data binding.

Posted on 2007-04-08
4
3,091 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
  • 2
4 Comments
 
LVL 15

Expert Comment

by:igor_alpha
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...)) The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

771 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

14 Experts available now in Live!

Get 1:1 Help Now