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

DataList: How to create a separator that spans across all items

I have a datalist that repeats horizontally by 3. I'm trying to create
a header that will be dynamically displayed based on criteria. Let's
say we have 3 groups (A, B, C). I want it to do this:

---THIS IS A GROUP------
--------- --------- ---------
Item1 Item2 Item3
--------- --------- ---------

---------
Item4
---------

---THIS IS B GROUP------
--------- --------- ---------
Item1 Item2 Item3
--------- --------- ---------

---THIS IS C GROUP------
--------- ---------
Item1 Item2
--------- ---------

Any Ideas?

Jun 13 '06 #1
2 2445

Did you ever find a way to do this? I have the exact same problem.

Jun 23 '06 #2

jk*******@gmail.com wrote:
Did you ever find a way to do this? I have the exact same problem.
I had to work around this. I used three datalists and three tables. I
used a data apapter and then created manual filters on the
ItemDataBound. Here's the example:
<!--HTML CODE-->
<html>
<head><style type=text/css>
.hidden {display:none;}
</style>
</head>
<body>
<!--A GROUP-->
<asp:Table ID="tblA" Runat=server Visible=False Width=100%>
<asp:TableRow><asp:TableCell
Width=100%><b>A-GROUP</b></asp:TableCell></asp:TableRow></asp:Table>

<asp:DataList id="dlA" runat="server" RepeatColumns="4"
RepeatDirection="Horizontal">
<itemtemplate>
<asp:label id="lblGroupLetter" runat=server text='<%#
Container.DataItem("groupletter")%>' Visible=False />
<!-- CODE HERE-->

</itemtemplate>
</datalist>

<!--B GROUP-->
<asp:Table ID="tblB" Runat=server Visible=False Width=100%>
<asp:TableRow><asp:TableCell
Width=100%><b>B-GROUP</b></asp:TableCell></asp:TableRow></asp:Table>
<asp:DataList id="dlC" runat="server" RepeatColumns="4"
RepeatDirection="Horizontal">
<itemtemplate>
<asp:label id="lblGroupLetter" runat=server text='<%#
Container.DataItem("groupletter")%>' Visible=False />
<!-- CODE HERE-->

</itemtemplate>
</datalist>

<!--C GROUP-->
<asp:Table ID="tblC" Runat=server Visible=False Width=100%>
<asp:TableRow><asp:TableCell
Width=100%><b>C-GROUP</b></asp:TableCell></asp:TableRow></asp:Table>

<asp:DataList id="dlC" runat="server" RepeatColumns="4"
RepeatDirection="Horizontal">
<itemtemplate>
<asp:label id="lblGroupLetter" runat=server text='<%#
Container.DataItem("groupletter")%>' Visible=False />
<!-- CODE HERE-->

</itemtemplate>
</datalist>
</body>
</html>

<!--CODE BEHIND-->

'Get the data and bind it to all datalists
Dim adapter As SqlDataAdapter
Dim dt As New DataTable

cmd = New SqlCommand("qryGroups", c)
cmd.CommandType = CommandType.StoredProcedure
c.Open()

adapter = New SqlDataAdapter(cmd)
adapter.Fill(ds)

dlA.DataSource = ds.Tables(0)
dlA.DataBind()
dlB.DataSource = ds.Tables(0)
dlB.DataBind()
dlC.DataSource = ds.Tables(0)
dlC.DataBind()

'''''The following needs to exist for dlA & dlB, but they would all be
the same except for the groupletter filter.
Private Sub dlC_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlC.ItemDataBound
Dim groupletter As String

groupletter = CType(e.Item.FindControl("lblGroupLetter"),
Label).Text

If groupletter = "C" Then
dlC.Visible = True
tblC.Visible = True
Else
'Otherwise, clear the result
e.Item.CssClass = "hidden"
e.Item.Visible = False
e.Item.Controls.Clear()
End If
End Sub

Jul 13 '06 #3

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

Similar topics

1
by: Mike Malter | last post by:
I take it that the only way to add rows to a DataList control is through DataBind? If not, how do I manually add rows to a DataList control? I have searched everywhere and can't find an example...
2
by: Leszek Taratuta | last post by:
Hello, I have a quick question: How to specify the height of the SeparatorTemplate (that is rendered as <td> tag) in DataList? Thanks, Leszek Taratuta
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
3
by: Barbara Alderton | last post by:
I recently wrote an ASP.NET app that used user controls. I produced a printer-friendly output form. One requirement was a pagebreak between one part of the form and another. I had no problem...
0
by: Xiru | last post by:
I would like to retrieve the value from a DataList on postback. I can read the ItemIndex and values from a child TextBox but not cannot seem to find a way to read a databound item on the datalist....
1
by: Paul Say | last post by:
Here is the problem, I have a datalist that builds a list of links horizontally across the screen for a menu bar. i.e <asp:datalist id="menuTabs" runat="server> <ItemTemplate>...
0
by: s.gregory | last post by:
My page layout is like this: Page >DataList (databound using ObjectDataSource1 contained in page) >>Items >>>UserControl >>>>GridView (databound using another ObjectDataSource2 contained in...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
0
by: =?Utf-8?B?UGF1bCBT?= | last post by:
Hi I want to make a 2-column list of historical data grouped by date. Each group of data must have a separator that spans over both columns. I have tried to do it with a datalist but the separator...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.