473,405 Members | 2,415 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,405 software developers and data experts.

Databinding with Sortedlist

Hi Guys,

I have a sortedlist which holds a group of "CartItem" items. following is
the CartItem class:

Public Class CartItem
Public ProdID As Integer
Public Name As String
Public Price As Decimal
Public Quantity As Integer
End Class

I have a datalist control and want to bind a label to the Name property of
the CartItem(s) in the sortedlist - the result shoud be that for each item in
the sorted list will create a new entry in the datalist control with the data
in the Name property showing in the label.

My binding sub:
Dim ShoppingCart as sortedlist = Session("Cart")
dlsCart.DataSource = ShoppingCart.Values
dlsCart.DataBind()

The label text property binding string:
DataBinder.Eval(Container.DataItem, "Name")
When I run this, I get the followig exception:

ExTYPE: System.Web.HttpException
MESSAGE: DataBinder.Eval: 'myLNF.CartItem' does not contain a property
with the name Name.
What am I doing wrong?

Nov 21 '05 #1
2 2182
Hi,

When you databind to a collection you must bind to a property.
Change you class to this.

Public Class CartItem
Private mProdID As Integer
Private mName As String
Private mPrice As Decimal
Private mQuantity As Integer

Public Property ProdID() As Integer
Get
Return mProdID
End Get
Set(ByVal value As Integer)
mProdID = value
End Set
End Property

Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property

Public Property Price() As Decimal
Get
Return mPrice
End Get
Set(ByVal value As Decimal)
mPrice = value
End Set
End Property

Public Property Quanity() As Integer
Get
Return mQuantity
End Get
Set(ByVal value As Integer)
mquanity = value
End Set
End Property
End Class

Ken
-----------------
"Ori :)" <Or*@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
Hi Guys,

I have a sortedlist which holds a group of "CartItem" items. following is
the CartItem class:

Public Class CartItem
Public ProdID As Integer
Public Name As String
Public Price As Decimal
Public Quantity As Integer
End Class

I have a datalist control and want to bind a label to the Name property of
the CartItem(s) in the sortedlist - the result shoud be that for each item
in
the sorted list will create a new entry in the datalist control with the
data
in the Name property showing in the label.

My binding sub:
Dim ShoppingCart as sortedlist = Session("Cart")
dlsCart.DataSource = ShoppingCart.Values
dlsCart.DataBind()

The label text property binding string:
DataBinder.Eval(Container.DataItem, "Name")
When I run this, I get the followig exception:

ExTYPE: System.Web.HttpException
MESSAGE: DataBinder.Eval: 'myLNF.CartItem' does not contain a property
with the name Name.
What am I doing wrong?
Nov 21 '05 #2
Works :D

Thanks!!!

"Ken Tucker [MVP]" wrote:
Hi,

When you databind to a collection you must bind to a property.
Change you class to this.

Public Class CartItem
Private mProdID As Integer
Private mName As String
Private mPrice As Decimal
Private mQuantity As Integer

Public Property ProdID() As Integer
Get
Return mProdID
End Get
Set(ByVal value As Integer)
mProdID = value
End Set
End Property

Public Property Name() As String
Get
Return mName
End Get
Set(ByVal value As String)
mName = value
End Set
End Property

Public Property Price() As Decimal
Get
Return mPrice
End Get
Set(ByVal value As Decimal)
mPrice = value
End Set
End Property

Public Property Quanity() As Integer
Get
Return mQuantity
End Get
Set(ByVal value As Integer)
mquanity = value
End Set
End Property
End Class

Ken
-----------------
"Ori :)" <Or*@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
Hi Guys,

I have a sortedlist which holds a group of "CartItem" items. following is
the CartItem class:

Public Class CartItem
Public ProdID As Integer
Public Name As String
Public Price As Decimal
Public Quantity As Integer
End Class

I have a datalist control and want to bind a label to the Name property of
the CartItem(s) in the sortedlist - the result shoud be that for each item
in
the sorted list will create a new entry in the datalist control with the
data
in the Name property showing in the label.

My binding sub:
Dim ShoppingCart as sortedlist = Session("Cart")
dlsCart.DataSource = ShoppingCart.Values
dlsCart.DataBind()

The label text property binding string:
DataBinder.Eval(Container.DataItem, "Name")
When I run this, I get the followig exception:

ExTYPE: System.Web.HttpException
MESSAGE: DataBinder.Eval: 'myLNF.CartItem' does not contain a property
with the name Name.
What am I doing wrong?

Nov 21 '05 #3

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

Similar topics

1
by: gerrod | last post by:
Hi - Does anyone know a way to created a SortedList (in the System.Collections namespace) that will sort on VALUES instead of KEYS... ? The scenario is this - I have a SortedList containing...
2
by: Pekka | last post by:
Could somebody say why the piece of code below does not work? My purpose is to renumber keys in a SortedList (after removal of an item) so that the keys would always contain an unbroken sequence of...
2
by: Ben Mann | last post by:
Hi There, Ive got an ASP .Net page with a listbox element. This listbox element is databound to a sorted list filled with keys and values from the database: dbReader =...
2
by: Nathan Sokalski | last post by:
I am using a SortedList as my DataSource. However, one of the things I am using the data for is to generate the URL for the HyperLinks in my DataList. Therefore, I need to use the result of a...
2
by: KrippZ | last post by:
Hello I'm having some problems with a a sortedList in C#. My set is as follows: I have a sortedList as a class variable (DataList) I inisiate it in my constructor with DataList = new SortedList()....
2
by: Prez | last post by:
I started writing .net code yesterday and I am grasping it well enough. I have a few questions about SortedLists. I am using managed C++ if that makes any difference. Of the examples I...
4
by: aeshiels | last post by:
Hello, I have a SortedList defined as... SortedList<CUser, CUseruserList = new SortedList<CUser, CUser>(); ....and which to copy it to another sorted list SortedList<CUser,...
1
by: raylopez99 | last post by:
I seem to get name collision between the Generic collection SortedList and C++.NET Framework collection SortedList. How to resolve? Here are the libraries that seem to clash:...
6
by: n3tx | last post by:
Hi! I have a problem with sortedlist, i guess i dont understand how it works. I have a method called GetPublishingPlaces that returns an IList<PublishingPlace> (ex. contains 11 rows) I want...
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:
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...
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
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,...
0
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...

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.