Hi,
I am new to ASP.NET and am having problems trying to develop a fairly simple
user control.
I have a DB table similar to the following -
Category,Item
cat1,item1
cat1,item2
cat1,item3
cat2,item1
cat2,item2
and I want to use it to generate simple bulletted lists, such as -
cat1
-item1
-item2
-item3
cat2
-item1
-item2
The following is a sample of my code -
01: <%@ Import Namespace="System.Data" %>
02: <%@ Import Namespace="System.Data.OleDb" %>
03:
04: <script language="VB" runat="server">
05: dim conn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\Martin\list.mdb")
06: dim ds as DataSet = new DataSet()
07:
08: sub Page_Load(Sender as Object, e as EventArgs)
09: 'open connection
10: dim cmdGetCat as new OleDbDataAdapter("SELECT DISTINCT category FROM
list",conn)
11: dim cmdGetItems as new OleDbDataAdapter("SELECT * FROM list", conn)
12:
13: 'fill dataset
14: cmdGetCat.Fill(ds, "Categories")
15: cmdGetItems.Fill(ds, "Items")
16:
17: 'bind to server control
18: rptrCategories.DataSource = ds.Tables("Categories").DefaultView
19: DataBind()
20: end sub
21:
22: sub rptrCategories_ItemCreated(Sender As Object, e As
RepeaterItemEventArgs)
23: rptrItems.DataSource = ds.Tables("Items").Select("category = '" &
e.Item.Container.DataItem("category") & "'")
24: DataBind()
25: end sub
26:
27: </script>
28:
29: <ASP:Repeater id="rptrCategories"
OnItemCreated="rptrCategories_ItemCreated" runat="server" >
30: <ItemTemplate>
31:
32: <font size="3" face="Arial, Helvetica, sans-serif"><%#
Container.DataItem("category") %></font><br>
33:
34: <ASP:Repeater id="rptrItems" runat="server" >
35: <HeaderTemplate>
36: <ul>
37: </HeaderTemplate>
38:
39: <ItemTemplate>
40: <li><font size="2" face="Arial, Helvetica, sans-serif"><%#
Container.DataItem("item") %></font></li>
41: </ItemTemplate>
42:
43: <FooterTemplate>
44: </ul>
45: </FooterTemplate>
46: </ASP:Repeater>
47: </ItemTemplate>
48: </ASP:Repeater>
I have a few problems with this -
1/ When I try to use it I get "Compiler Error Message: BC30451: Name
'rptrItems' is not declared." for line 23. It is declared on line 34. Is it
something to do with the fact that the sub is related to the parent repeater
and not the page object?
2/ Once I get problem 1 solved I am actually still expecting a problem with
line 23. Specifically, I made a wild guess at how to access the current
value of the parent repeater and used
"e.Item.Container.DataItem("category")", will this work and, if not, what
would?
3/ What will be the effect of the multiple databinds?
4/ I would prefer to only connect to the DB once, get the contents of the
table and manipulate the dataset to get my values. But, there doesn't seem
to be a way of filtering a datatable to obtain distinct values.
Sorry about all the questions.
Thanks
Martin 0 903 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave H |
last post by:
Hello,
I have a query regarding definition lists. Is it good practice
semantically to use the dt and dd elements to mark up questions and
answers in a frequently asked questions list, or FAQ?
...
|
by: Martin |
last post by:
Hi,
I am new to ASP.NET and am having problems trying to develop a fairly simple
user control.
I have a DB table similar to the following -
Category,Item
cat1,item1
cat1,item2
|
by: Odd-R. |
last post by:
I have to lists, A and B, that may, or may not be equal. If they are not
identical, I want the output to be three new lists, X,Y and Z where X has
all the elements that are in A, but not in B, and...
|
by: s_subbarayan |
last post by:
Dear all,
1)In one of our implementation for an application we are supposed to
collate two linked lists.The actual problem is like this:
There are two singularly linked lists, the final output...
|
by: Simon Forman |
last post by:
I've got a function that I'd like to improve.
It takes a list of lists and a "target" element, and it returns the set
of the items in the lists that appear either before or after the target...
|
by: Gal Diskin |
last post by:
Hi,
I am writing a code that needs to iterate over 3 lists at the same
time, i.e something like this:
for x1 in l1:
for x2 in l2:
for x3 in l3:
print "do something with", x1, x2, x3
What I...
|
by: Michael M. |
last post by:
How to find the longst element list of lists?
I think, there should be an easier way then this:
s1 =
s2 =
s3 =
if len(s1) >= len(s2) and len(s1) >= len(s3):
sx1=s1 ## s1 ist längster
|
by: Joerg Schoen |
last post by:
Hi folks!
Everyone knows how to sort arrays (e. g. quicksort, heapsort etc.)
For linked lists, mergesort is the typical choice.
While I was looking for a optimized implementation of mergesort...
|
by: Joeyeti |
last post by:
Hi fellow VB knowers (I am but a learner still).
I have a question for you which I struggle with. I need to convert nested Lists in MS WORD (whether numbered or bulleted or mixed) from their...
|
by: Qbert16 |
last post by:
Hi, I'm quite new to python and am looking for help with lists inside lists
This is an example I'm trying to do. I have the following thesaurus set...
thesaurus = ,
...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |