473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Argument Exception: 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:textbo x id=txtExpiratio nDate runat="server" Text='<%#
DataBinder.Eval (dsMain1, "Tables[Links].DefaultView.[0].ExpirationDate ")
%>'></asp:textbox></TD>
Line 64: <TD></TD>
Line 65: <TD rowSpan="4"><as p:listbox id=lstCategory runat="server"
DataValueField= "ID" DataTextField=" Category" DataMember="Cat egory"
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\wwwr oot\Quixor\link s\LinkAdd.aspx Line: 65
--

/\_Ray Valenti ____ http://www.quixor.com ______
\/ Quixor Flex Systems, Ltd.
Nov 18 '05 #1
1 4005
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.va lue
as i recall

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

then just access it dropdownlist.se lecteditem.valu e

if not then i guess you could always delimit a field and slap it in the
value field
"Ray Valenti" <RV******@neo.r r.com> wrote in message
news:Vk******** ***********@fe2 .columbus.rr.co m...
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.Argument Exception: 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:textbo x id=txtExpiratio nDate runat="server" Text='<%# DataBinder.Eval (dsMain1, "Tables[Links].DefaultView.[0].ExpirationDate ")
%>'></asp:textbox></TD>
Line 64: <TD></TD>
Line 65: <TD rowSpan="4"><as p:listbox id=lstCategory runat="server"
DataValueField= "ID" DataTextField=" Category" DataMember="Cat egory"
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\wwwr oot\Quixor\link s\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
4203
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), SqlConnection (sqlConnection), SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet (dsLookupData), and DataSet (dsData), all created via the IDE during design-time. Here is the design of my simple tables: (An example since I can't post my...
5
3470
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 Employee that contains public properties and several nested objects such as a Spouse object and a List of Coverage objects.
1
2565
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 array, ArrayList, Collection as public vars in the Form Class's Declarations section. Setting the DataSource property to any of these works fine at run time. I want to do it at design time because after I change the Collection, it doesn't...
3
7754
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 the form. (It's a Company -> People -> Personal Data relationship) When I bind my datasource to the ListBox, I find that the
2
2184
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 this case, is often blank. How can I get the DataBinding to go... "if Company is blank, use ContactName, else use Company"
0
1273
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 in the listbox, the values of that collection item can be set but if an identical collection item is also present in the listbox, its variables are set as well. I think it has something to do with the SelectedIndexChanged and databinding. I have...
8
2083
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 generic type Field<T> (see sample code). public class Employee { public Field<stringForename
9
3215
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). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this selection. I am using an SQLDataSource web control for this. These items are headers. I want, when...
1
1875
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? Thanks, Shimon
0
8850
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.