By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,683 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,683 IT Pros & Developers. It's quick & easy.

Mix the ASP.net code behind and the HTML

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.