473,396 Members | 1,743 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,396 software developers and data experts.

Simple Nested Datalist

Hi there,

I have a simpletable that i have succesfully bound to a datalist..

It just shows name, description and image.. FINE.. However i would now
like to simply split them into sections i.e 1,2,3,4.. So i added
another field to the table called section..

However this is proving really hard.. Basically all i want is:

1..............
section1
2............
section2
3............
section3

This is basic as it gets so i dont really want to add a new table just
for these section categories.. Can this be achieved by using an array
for the categories or something similar
Nov 18 '05 #1
1 1233
The right way to do it would be to add another table, with a relationship
and nest your grids.

The only alternative I can think of is to do complicated stuff
onItemDataBound checking to see if the section has changed:

<ItemTemplate>
<tr id="sectionHeader" runat="server">
<td colspan="2"><%# Databinder.Eval(Container.DataItem, "SectionId")
%></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><%# Databinder.Eval(Container.DataItem, "Name") %></td>
</tr>
</ItemTemplate>

then onItemDataBound
private int oldSectionId = 0;

if (e.Item.ItemType == Item || e.Item.ItemType == AlternatingItem){
HtmlTableRow tr = (HtmlTableRow)e.item.FindControl("sectionHeader");
int sectionId = Convert.ToInt32(((DataRowView)e.DataItem)["sectionId"]);
if (sectionId != oldSectionId){
oldSectionId = sectionId;
tr.visible = true;
}else{
tr.visible = false;
}
}

Code is just off the top of my head, so won't compile, but it ought to give
you an idea. You can check out my article on DataBinding for more on
OnItemDataBound and Nested controls:
http://openmymind.net/databinding/index.html

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anthony" <an***********@hotmail.com> wrote in message
news:77**************************@posting.google.c om...
Hi there,

I have a simpletable that i have succesfully bound to a datalist..

It just shows name, description and image.. FINE.. However i would now
like to simply split them into sections i.e 1,2,3,4.. So i added
another field to the table called section..

However this is proving really hard.. Basically all i want is:

1..............
section1
2............
section2
3............
section3

This is basic as it gets so i dont really want to add a new table just
for these section categories.. Can this be achieved by using an array
for the categories or something similar

Nov 18 '05 #2

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

Similar topics

1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
0
by: Marty U. | last post by:
I have two datalists nested. On the ItemDataBound Event of the first datalist I databind the second with specific info. A couple questions: 1) How can I utilize the OnItemCommand of the nested...
3
by: Derek | last post by:
I have a nested datalist with a dropdownlist. I need to capture the selectedvalue of the dropdownlist so I can update a database table. My question then is...how do I get the value from the...
0
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
3
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS...
0
by: H5N1 | last post by:
Hi there My problem is that in when I update GridView row, which is nested into DataList control, I want to refresh also DataList in which the GridView is nested, since after update, trigger in...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
2
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me...
1
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList...
2
by: Ole V.-M. | last post by:
Greetings, i have a UserControl, that contains a DataList. That DataList contains as items other DataLists. example: DataList A Row 1 Nested DataList 1 Row 1
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.