473,624 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with datalist and server tags

I hope someone can help with this, because it’s driving me crazy. It’s also
a little tough to describe what’s happening, but I’ll do my best.

I have a class that takes a ProductID and then uses it to generate some
html. I then insert that HTML into my page via server tags. I’m using a
datalist for the content, making a 3 x 3 grid.

For each instance of my ItemTemplate, I’m changing a pic, some text, a link
button, and my class-generated html. The first three change for each new
ProductID. However, the stuff between the server tags appears to be running
only after the entire page is rendered, meaning that my class is called nine
times with the same ProductID.

I’ve included below the code that I think must contain the problem. The
class does it’s job fine. The ProductID is also changing in
list_ItemDataBo und(). I can post the class too if it’ll be helpful, but this
post is already getting long.

Thanks for any help.

-Josh Nikle
// Snip from my aspx page
…<asp:LinkBut ton ID="addToCartBu tton" runat="server" Text="Buy now!"
CommandArgument ='<%# Eval("ProductID ") %>'></asp:LinkButton| <a
href='Product.a spx?ProductID= <%# Eval("ProductID ")
%>'>Info</a></font></strong>
</td>
</tr>
<tr height=14 width="100%">
<td align="center" valign="middle" colspan=2 class="SectionH eader">
<%
prodID = productID;
catBrowse = new BrowseCategory( prodID);
Response.Write( catBrowse.brows eCategoryHTML() );
%>
</td>
</tr>…
// My variable list at the top of the aspx.cs file
protected BrowseCategory catBrowse;
protected int prodID;
protected int productID;
// Gets the ProductID to pass to the BrowseCategory class
protected void list_ItemDataBo und(object sender, DataListItemEve ntArgs e)
{
productID = Convert.ToInt32 (DataBinder.Eva l(e.Item.DataIt em,
"ProductID" ));

}
Mar 23 '07 #1
2 1399
<%
prodID = productID;
catBrowse = new BrowseCategory( prodID);
Response.Write( catBrowse.brows eCategoryHTML() );
%>
<% %blocks have different timing of *execution* than timing(s) of <
%# %*evaluation*.

Replace this <% %block with following line (code behind not needed)

<asp:Literal runat="server" ID="Literal1" EnableViewState ="false"
Text='<%# new
BrowseCategory( Convert.ToInt32 (Eval("ProductI D"))).browseCat egoryHTML()
%>' />

Mar 24 '07 #2
works perfectly! thanks. this was making me crazy. thanks too for the
extra info on execution and evaluation.

-josh
Mar 28 '07 #3

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

Similar topics

1
4771
by: Kevin | last post by:
Hi all, I'm now very frustrated, I've been battling all of today to try and understand the datalist, editing, inserting, updating, etc, I have managed to get most of that sort of stuff working(Thank goodness:)). But now I would like to implement validation on my datalist, but I am just not getting it right :(( I have got labels in my item template wich of course hold the data coming from my database. I also have a button called edit and when...
7
1303
by: neverstill | last post by:
hi- I have <a> tags in my DataList. For the href property, I want to do something like this: <a href='~/Default.aspx?show=Support&disp=Faq&p=<%# DataBinder.Eval(Container.DataItem, "name")%>' runat=server>some link</a> Looks pretty straight forward, but when I add the runat=server property it stops parsing the <% %> block correctly.
1
2781
by: Jim Heavey | last post by:
I am unable to get the data list to render the AlternateStyle.... Any ideas as to why? <Table title="Calendar Maintenance" > <asp:datalist id="dlCalendar" runat="server" OnItemCreated="OnItemCreated" GridLines="Both" CellSpacing="2" DataKeyField="Time_ID" OnUpdateCommand="CalendarOnUpdate" OnEditCommand="CalendarOnEdit" OnCancelCommand="CalendarOnCancel"> <EditItemStyle ForeColor="Black" BackColor="#99ccff"></EditItemStyle>
2
3594
by: Wayne Wengert | last post by:
I have an aspx page I originzlly built in WebMatrix that includes a "<table>" structure to layout the columns using "<tr>" and "<td>" elements (see sample below). When I create a new aspx form in my VSNE2003 solution, add a datalist component with table layout and paste that code, it doesn't like the table related tags (<table>, <tr>, etc.). Using VSNET2003 what is the correct way to specify the "table" layout (rows and columns) ...
6
9579
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
3
1690
by: Jon Paal | last post by:
how do I load controls to the templates for the DataList control. <asp:datalist id="dl1" runat="server" > <ItemTemplate> " how to load control(s) here ????" </ItemTemplate> </asp:datalist>
1
4012
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing wrong. I have simplified the problem with the following example: Using asp.net 2.0, I have a Master page template used on default.aspx. >From within the Content tags on that page I placed a Datalist. It is iterating a User control "Inner" with...
1
1260
by: studen771 | last post by:
Thanks in advance to anyone who can help :) I'm fairly new to templated asp.net controls- my dataList is not appearing- its very simple and all of the code is being placed inline via tags. Here's the code: <asp:DataList ID="dtList" runat="server"><HeaderTemplate><table><tr style="background-color:#0000cc;color:#FFFFFF"><th>Name</th><th>Phone Number</th><th>Title</th></tr></HeaderTemplate> <ItemTemplate><tr><td>Joe
5
1450
by: Aussie Rules | last post by:
Hi, I am still having a problem using a datalist control using VB.net This is my code...... In the HTML page I have <asp:DataList ID="DataList1" runat="server">
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8629
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.