[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to create dynamic links from a database

Posted on 2008-11-04
3
Medium Priority
?
842 Views
Last Modified: 2013-12-17
I am able to pull a list of stories from a database, however, I want to pull a list of stories and link to the page that displays the story.  For example I want to list the story title and have the story title be a link that links to page that displays a story based on the story ID.  

I can display the list of stories, and I have a page that will display the story based on an ID, however, how to I create the link for the title?

<a href="story.aspx?ID='storyID'>Story Title</a>

That is what I am trying todo.  

Thank you for any advice.  I am using c# with SQL server back end.
0
Comment
Question by:shanemay
3 Comments
 
LVL 7

Expert Comment

by:the_bachelor
ID: 22882486
Well a real rudimental way is to have
1. a Table (say tblStory with Columns StoryID, Title, Body)
2. you have maye a stored procedure that takes a storyID as a parameter and retrieves the table row associated with the ID
3. on the Story.aspx you have place holders to display the Title and the body.
0
 
LVL 6

Accepted Solution

by:
M3mph15 earned 2000 total points
ID: 22882758
Hi,
What i could do is use a repeater and bind to it an SqlDataSource that retrieves Story ID and Stroy Title.
SqlDataSource would have a Select statemnt like "SELECT STORY_ID, STORY_NAME FROM STORY".

<asp:Repeater ID="repParty" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
                 <a href="<%FormatUrl(DataBinder.Eval(Container.DataItem, "STORY_ID")) %>"><%#DataBinder.Eval(Container.DataItem, "STORY_NAME")%></a>
        </ItemTemplate>
</asp:Repeater>

And then in the code behind file put this function:
public string FormatUrl(string id)
{
    string url = "story.aspx?ID=" + id;
    return url;
}

Hope This Helps
-M3mph15
0
 

Author Closing Comment

by:shanemay
ID: 31513331
Thank you for the help, with a little bit of modification that worked excatly like I needed it to.  I really appericiate your help.  Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 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