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

Datagrid binding

hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought list
boxes did implement one of the above as they do have their items collection
property,
can anyone help?
Sep 3 '05 #1
10 3065
ShadowsOfTheBeast wrote:
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,


I'm not completely sure I understand you correctly - a bit of sample code
about what you are doing could have helped. But I assume you are trying to
bind the list box directly to the grid, like this:

myDataGrid.DataSource = myListBox;

This won't work because it's not the list box that implements the
collection interface, it's only the object returned by the Items property.
This is a special collection for use with the ListBox and it implements
IList. So you should be fine if you use a line like this to do the binding:

myDataGrid.DataSource = myListBox.Items;
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Sep 4 '05 #2
hi oliver thanks for your help i kinda figured that out minutes
afterwards...but what i am actually trying to do is this:

i have a listbox control that gets its data from another listbox (hence gets
a subset by selecting from the first list box) and i have a datagrid which
has a template column and a bound column, i want to bind the bound column to
this second listbox and then its template column implements a dropdownlist
for every bound column item, now this dropdownlist (in the template column of
the datagrid) i want to bind it to a dataset's datatable

"Oliver Sturm" wrote:
ShadowsOfTheBeast wrote:
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,


I'm not completely sure I understand you correctly - a bit of sample code
about what you are doing could have helped. But I assume you are trying to
bind the list box directly to the grid, like this:

myDataGrid.DataSource = myListBox;

This won't work because it's not the list box that implements the
collection interface, it's only the object returned by the Items property.
This is a special collection for use with the ListBox and it implements
IList. So you should be fine if you use a line like this to do the binding:

myDataGrid.DataSource = myListBox.Items;
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Sep 4 '05 #3
hi oliver thanks for your help i kinda figured that out minutes
afterwards...but what i am actually trying to do is this:

i have a listbox control that gets its data from another listbox (hence gets
a subset by selecting from the first list box) and i have a datagrid which
has a template column and a bound column, i want to bind the bound column to
this second listbox and then its template column implements a dropdownlist
for every bound column item, now this dropdownlist (in the template column of
the datagrid) i want to bind it to a dataset's datatable

I have already created a dropdownlist that gets the data from a dataset but
how do i implement this whithin the datagrid in a
<templatecolumn><itemTemplate>
i cant seem to do this can you please help?

"Oliver Sturm" wrote:
ShadowsOfTheBeast wrote:
hi all i am trying to bind data to my datagrid from a listbox which i think
it should work but an error is coming up saying i have to bind to a
datasource that implements the Inumerable or icollection...but i thought
list
boxes did implement one of the above as they do have their items collection
property,


I'm not completely sure I understand you correctly - a bit of sample code
about what you are doing could have helped. But I assume you are trying to
bind the list box directly to the grid, like this:

myDataGrid.DataSource = myListBox;

This won't work because it's not the list box that implements the
collection interface, it's only the object returned by the Items property.
This is a special collection for use with the ListBox and it implements
IList. So you should be fine if you use a line like this to do the binding:

myDataGrid.DataSource = myListBox.Items;
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Sep 4 '05 #4
ShadowsOfTheBeast wrote:
hi oliver thanks for your help i kinda figured that out minutes
afterwards...but what i am actually trying to do is this:

i have a listbox control that gets its data from another listbox (hence
gets
a subset by selecting from the first list box) and i have a datagrid which
has a template column and a bound column, i want to bind the bound column
to
this second listbox and then its template column implements a dropdownlist
for every bound column item, now this dropdownlist (in the template column
of
the datagrid) i want to bind it to a dataset's datatable

I have already created a dropdownlist that gets the data from a dataset but
how do i implement this whithin the datagrid in a
<templatecolumn><itemTemplate>
i cant seem to do this can you please help?


I'm sorry. I only just realized that you are talking about a DataGrid as a
web control, and I really can't tell you much about that because I have
never used it. I expect somebody else will be able to help you with the
details of that setup.

Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Sep 4 '05 #5
Oliver Sturm wrote:
I'm sorry. I only just realized that you are talking about a DataGrid as a
web control, and I really can't tell you much about that because I have
never used it. I expect somebody else will be able to help you with the
details of that setup.


And I should have said that it's probably a good idea to post this to a
more specific group like aspnet.datagridcontrol.
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Sep 4 '05 #6
thanks oliver they work very similarly but the web one is a bit more
annoying!!!
can you tell me where to find the news group you reccommended i cant find it?

"Oliver Sturm" wrote:
Oliver Sturm wrote:
I'm sorry. I only just realized that you are talking about a DataGrid as a
web control, and I really can't tell you much about that because I have
never used it. I expect somebody else will be able to help you with the
details of that setup.


And I should have said that it's probably a good idea to post this to a
more specific group like aspnet.datagridcontrol.
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Sep 4 '05 #7
Shadow,

You should give in my opinion good information. With telling us that you are
using a listbox that implements Icollection, are you in my opinion telling
that you use a windows.form.listbox. You bring us therefore completely in a
wrong direction and all time spent on you is a waste.

However see this sample, it is for a windowsform listbox. However the way
to handle this is basicly not diverent for a webform.

http://www.windowsformsdatagridhelp.com/default.aspx

I hope this helps,

Cor
Sep 4 '05 #8
ShadowsOfTheBeast wrote:
can you tell me where to find the news group you reccommended i cant find
it?


The group I meant was
"microsoft.public.dotnet.framework.aspnet.datagrid control" and it should
be on the same news server that you're currently posting to.
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Sep 4 '05 #9
Hi Cor,
sorry about that, that was the error i was getting... but like i said i
figured that one out pretty quickly, I am developing in asp.net and am
trying to bind a listbox web server control to a datagrid web server control
(to be specific) to a bound column in my datagrid, i also have a template
column in my datagrid that uses a dropdownlist web server control...now
normally binding a dropdownlist control to a dataSet is easy and i can do
that...but when you have the dropdownlist in the datagrid how do you do this
(that is still have it bound to a dataset's datatable?)

by the way i cant get to the page you sent me ...gettign a " The page cannot
be displayed" error.

many thanks

"Cor Ligthert [MVP]" wrote:
Shadow,

You should give in my opinion good information. With telling us that you are
using a listbox that implements Icollection, are you in my opinion telling
that you use a windows.form.listbox. You bring us therefore completely in a
wrong direction and all time spent on you is a waste.

However see this sample, it is for a windowsform listbox. However the way
to handle this is basicly not diverent for a webform.

http://www.windowsformsdatagridhelp.com/default.aspx

I hope this helps,

Cor

Sep 4 '05 #10
Shadow,

I forgot to set the link it is on this page.

Try this one, keep in mind that the propertynames for the webform listbox
are different. (And you have to store your dataset in a session during post
and postback.

http://www.windowsformsdatagridhelp....2-d663cbcccb64
I hope this helps better,

Cor
Sep 4 '05 #11

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

Similar topics

6
by: Shivang | last post by:
Hello Everybody, I am using Datagrid in VB.net. I don't want the auto generation of rows in the datagrid (last row shouldnt be the new row with empty values)..in addition to this the datagrid...
0
by: Tom Hughes | last post by:
I want to change one field of all selected rows to a provided value. Problem 1 I am using the Binding Manager Base to bind the datagrid to the appropriate dataTable as recommended by KB817247....
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
4
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
6
by: Alpha | last post by:
I have several textboxes that I need to chang the text when the selection row is changed in a datagrid. I have the following code. This textbox displayes the initial selection but when I click on...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
5
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
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: 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
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
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
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.