473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Mix the ASP.net code behind and the HTML

Hi,

I have a need to extract some data from a sql database, which I store in a
dataset, and display this in a HTML list tag.

I have the result set in my code behind file, but have no idea on how to get
this into the HTML.

In the HTML I have this snippet

<ul>
<li><a href="somepage.aspx?param=1">Link Text</a></li>
<li><a href="somepage.aspx?param=1">Link Text</a></li>
<li><a href="somepage.aspx?param=1">Link Text</a></li>
</ul>
I want to be able to replace the param value, and the link text with values
from the SQL dataset in the code behind file
How can I do this ?

Thanks

Jun 4 '07 #1
2 1874
you can do it with datalist component.

<asp:DataList ID="DataList1" runat="server" DataKeyField="LinkId"
DataSourceID="SqlDataSource1">
<ItemTemplate>
LinkId:
<li><a href="somepage.aspx?param=<%# Eval("pramId")
%>"><%# Eval("yourcolumnname") %></a></li>

<br />
</ItemTemplate>
</asp:DataList></ul>

you have to set the sql datasource according to your query and

Jun 4 '07 #2
Hi Aussie,

As Hakan suggested, you can use some built-in template databound control to
author page UI that need to display dynamic content(list) based on data
records retrieved from database(datasource). And those built-in controls
like Repeater, DataList are good at this:

#Repeater Web Server Control
http://msdn2.microsoft.com/en-us/lib...ty(VS.71).aspx

#Databinding in Templates
http://quickstarts.asp.net/QuickStar...templates.aspx

In addition, for some general ASP.NET programming tasks, you can refer to
the ASP.NET quickstart site to get some ideas:

#ASP.NET 2.0 QuickStart Tutorial
http://quickstarts.asp.net/QuickStartv20/aspnet/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Jun 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Fox | last post by:
Hello, In VS.NET 2003 when I add server controls to the web form it sometimes adds their declarations to the code behind and sometimes not. Is there a way to tell VS.NET to parse the web form...
4
by: etropic | last post by:
Im confused I want an .aspx page to have a table with my data in it. At first I wrote FillTablew(); in my Page_Load even in the Code Behind file. I had it loop the db etc. and use Response.Write...
5
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
3
by: aaa | last post by:
I fail to see the connection between the code behind and the raw HTML of the ASPX page how do you get variables and functions to communicate with each other? I cannot get this to even fire:...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.