473,396 Members | 1,907 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.

Complex databinding with ASP Listbox

I have a ASP listbox that I am trying to populate with two fields, one for
display (Category) and one to store (ID) as the selected item. I can
successfully populate and view the list. How ever after specifying the
field to hold the selected value with the Databindings property, the error
below show up.

VS changes the DataSource from DSMain1 to the expression:
DataBinder.Eval(dsMain1, "Tables[Links].DefaultView.[0].fkeyCategory")

Can I bind to both the list source (two fields) and a field that holds the
selected value at the same time?

-Ray

---- error
returned -------------------------------------------------------------------
--------------------
An invalid data source is being used for lstCategory. A valid data source
must implement either IListSource or IEnumerable.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: An invalid data source is being
used for lstCategory. A valid data source must implement either IListSource
or IEnumerable.

Source Error:
Line 63: <TD><asp:textbox id=txtExpirationDate runat="server" Text='<%#
DataBinder.Eval(dsMain1, "Tables[Links].DefaultView.[0].ExpirationDate")
%>'></asp:textbox></TD>
Line 64: <TD></TD>
Line 65: <TD rowSpan="4"><asp:listbox id=lstCategory runat="server"
DataValueField="ID" DataTextField="Category" DataMember="Category"
DataSource='<%# DataBinder.Eval(dsMain1,
"Tables[Links].DefaultView.[0].fkeyCategory") %>' Width="150px"
Height="130px"></asp:listbox></TD>
Line 66: </TR>
Line 67: <TR>
Source File: c:\inetpub\wwwroot\Quixor\links\LinkAdd.aspx Line: 65
--

/\_Ray Valenti ____ http://www.quixor.com ______
\/ Quixor Flex Systems, Ltd.
Nov 18 '05 #1
1 3980
as far as i'm aware there is the listindex
which is just 0,1,2,3,4,5,....
there is the text that you see and there is the
value that you don't see but can read
selecteditem.value
as i recall

in the properties window
dataTextField - what you want to see
dataValueField - the useful info field

then just access it dropdownlist.selecteditem.value

if not then i guess you could always delimit a field and slap it in the
value field
"Ray Valenti" <RV******@neo.rr.com> wrote in message
news:Vk*******************@fe2.columbus.rr.com...
I have a ASP listbox that I am trying to populate with two fields, one for
display (Category) and one to store (ID) as the selected item. I can
successfully populate and view the list. How ever after specifying the
field to hold the selected value with the Databindings property, the error
below show up.

VS changes the DataSource from DSMain1 to the expression:
DataBinder.Eval(dsMain1, "Tables[Links].DefaultView.[0].fkeyCategory")

Can I bind to both the list source (two fields) and a field that holds the
selected value at the same time?

-Ray

---- error
returned ------------------------------------------------------------------- --------------------
An invalid data source is being used for lstCategory. A valid data source
must implement either IListSource or IEnumerable.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.ArgumentException: An invalid data source is being used for lstCategory. A valid data source must implement either IListSource or IEnumerable.

Source Error:
Line 63: <TD><asp:textbox id=txtExpirationDate runat="server" Text='<%# DataBinder.Eval(dsMain1, "Tables[Links].DefaultView.[0].ExpirationDate")
%>'></asp:textbox></TD>
Line 64: <TD></TD>
Line 65: <TD rowSpan="4"><asp:listbox id=lstCategory runat="server"
DataValueField="ID" DataTextField="Category" DataMember="Category"
DataSource='<%# DataBinder.Eval(dsMain1,
"Tables[Links].DefaultView.[0].fkeyCategory") %>' Width="150px"
Height="130px"></asp:listbox></TD>
Line 66: </TR>
Line 67: <TR>
Source File: c:\inetpub\wwwroot\Quixor\links\LinkAdd.aspx Line: 65
--

/\_Ray Valenti ____ http://www.quixor.com ______
\/ Quixor Flex Systems, Ltd.

Nov 18 '05 #2

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

Similar topics

4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
5
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object...
1
by: Stephen | last post by:
I have a form with a ListBox and would like to set the DataSource property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a traditional...
3
by: Alec MacLean | last post by:
Hi everyone, I have a ComboBox that when changed, calls a method to change the content of a ListBox. I'm also using the Listbox's SelectedIndexChanged event to change other control values on...
2
by: musosdev | last post by:
Hi guys I have an asp:ListBox on my form, which I'm populating with a DataReader, using DataSource/DataBind. The problem is that the main field I want to use for DataTextField, "Company" in...
0
by: bnolingberg | last post by:
Hi all. I've been stuck on this problem for a while (I'm a newbie). I have a listbox with several collection objects, some of them being identical. When one of the collection items is selected...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
1
by: Shimon Sim | last post by:
I have following scenario I have ListBox that is bound to BindingList<Person> Person has Address property that has Street property. How can I bind Street to a TextBlock in ListBox DataTemplate?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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.