Solved

Setting NavigateURL value using data binding.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

911 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

20 Experts available now in Live!

Get 1:1 Help Now