[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

bind a list box to an object data source in ASP.NET

Posted on 2009-07-14
13
Medium Priority
?
332 Views
Last Modified: 2012-06-27
Hello,
How can i bind a list box to an object data source
in a button click event.
i wrote :
listbox1.datasourceID = "objectdatasource1"
listbox1.databind

and i got in the list box rows having System.Data.DataRowView.
thanks
i am using VB
0
Comment
Question by:Nyana22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
13 Comments
 
LVL 15

Assisted Solution

by:jinal
jinal earned 800 total points
ID: 24850031
As i seen that you are binding datatable or DataView to listbox1.

So please set DataTextField and DataValueField . This is the name of DataTable Column.

listbox1.datasourceID = "objectdatasource1"
listbox1.DataTextField = ""   // Please provide this information
listbox1.DataValueField =""   // Please provide this information.
listbox1.databind()

Open in new window

0
 

Author Comment

by:Nyana22
ID: 24850076
ah yeah, the OS is bound to a function in the DAL, that returns a DataSet.
but why i need to do so, if i want to bind a datatable or...
thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24850118
>As i seen that you are binding datatable or DataView to listbox1.

The question title and the id of the datasource explicitely says its an OBJECTDATASOURCE not a datatable or dataview. But yes set the DataTextField and DataValueField properties appropriately.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Nyana22
ID: 24850129
didn't work
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24850133
>ah yeah, the OS is bound to a function in the DAL, that returns a DataSet.
Why not bind the dataset directly to list then?
0
 
LVL 15

Expert Comment

by:jinal
ID: 24850143
If you manually create listitem then its ok.

Like
listboxl.Items.Add(new ListItem("text1","value"));

But here you bind datatable or dataset that's why you have to provide that information.
0
 
LVL 15

Expert Comment

by:jinal
ID: 24850169
Can you please give me column name that return from objectdatasource.
0
 

Author Comment

by:Nyana22
ID: 24850344
warID
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24850423
I repeat my question:
If DAL is returing you a dataset, you could bind to this dataset directly without using an objectdatasource in between. Is there any reason for not taking this approach?
0
 

Author Comment

by:Nyana22
ID: 24850456
no, i just didn't understand!!
i am new to this,
can u please tell me how in vb code,
if the function returning a dataset is called FCT1. and the list box is LB1
thanks
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1200 total points
ID: 24850478
LB1.DataSource = FCT1()
LB1.DataTextField = "WarID"
LB1.DataValueField = "WarID"
LB1.DataBind()
0
 

Author Comment

by:Nyana22
ID: 24850753
thanks
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24850767
Is it working?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question