Noob question - binding data to list box (system.data.datarowview?)

Noob question - binding data to list box (system.data.datarowview?)

am 17.04.2008 17:51:24 von Arch Stanton

I'm trying to bind data in a dataset (obtained from an Access DB) to a
listbox in ASP.net. I know my dataset is being created properly because
it displays fine in a datagrid, but I can't get it to display in a
listbox. Here's what I'm trying:

dgrDataGrid.DataSource = dstData.Tables("Manufacturer")
lstMake.datasource = dstData.Tables("Manufacturer")
Page.DataBind

There is only one column in the dataset's table, and the datagrid
displays it the way I want. But my listbox just repeats the line
"system.data.datarowview" over and over.

Any help is, as usual, appreciated.

Re: Noob question - binding data to list box (system.data.datarowview?)

am 17.04.2008 18:23:05 von Courtney

"Arch Stanton" wrote in message
news:zZCdnSmRF8Ka75rVnZ2dnUVZ_sWdnZ2d@comcast.com...
> I'm trying to bind data in a dataset (obtained from an Access DB) to a
> listbox in ASP.net. I know my dataset is being created properly because it
> displays fine in a datagrid, but I can't get it to display in a listbox.
> Here's what I'm trying:
>
> dgrDataGrid.DataSource = dstData.Tables("Manufacturer")
> lstMake.datasource = dstData.Tables("Manufacturer")
> Page.DataBind
>
> There is only one column in the dataset's table, and the datagrid displays
> it the way I want. But my listbox just repeats the line
> "system.data.datarowview" over and over.
>
> Any help is, as usual, appreciated.

You need to tell the listbox what to display. The default is the .toString
so you are getting the object type as each occurence.

LS

Re: Noob question - binding data to list box (system.data.datarowview?)

am 17.04.2008 19:03:35 von David Wier

You need to tell it, from the dataset you get returned what to display and
what to assign to the 'value' of the item
Like Product for DataTextField and ProductID for DataValueField

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"Arch Stanton" wrote in message
news:zZCdnSmRF8Ka75rVnZ2dnUVZ_sWdnZ2d@comcast.com...
> I'm trying to bind data in a dataset (obtained from an Access DB) to a
> listbox in ASP.net. I know my dataset is being created properly because it
> displays fine in a datagrid, but I can't get it to display in a listbox.
> Here's what I'm trying:
>
> dgrDataGrid.DataSource = dstData.Tables("Manufacturer")
> lstMake.datasource = dstData.Tables("Manufacturer")
> Page.DataBind
>
> There is only one column in the dataset's table, and the datagrid displays
> it the way I want. But my listbox just repeats the line
> "system.data.datarowview" over and over.
>
> Any help is, as usual, appreciated.

Re: Noob question - binding data to list box (system.data.datarowview?)

am 18.04.2008 07:32:06 von Arch Stanton

Replies solved my problem. You guys rule.

-Grateful Noob :|



David Wier wrote:
> You need to tell it, from the dataset you get returned what to display and
> what to assign to the 'value' of the item
> Like Product for DataTextField and ProductID for DataValueField
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
> bloated markup
>
>
> "Arch Stanton" wrote in message
> news:zZCdnSmRF8Ka75rVnZ2dnUVZ_sWdnZ2d@comcast.com...
>> I'm trying to bind data in a dataset (obtained from an Access DB) to a
>> listbox in ASP.net. I know my dataset is being created properly because it
>> displays fine in a datagrid, but I can't get it to display in a listbox.
>> Here's what I'm trying:
>>
>> dgrDataGrid.DataSource = dstData.Tables("Manufacturer")
>> lstMake.datasource = dstData.Tables("Manufacturer")
>> Page.DataBind
>>
>> There is only one column in the dataset's table, and the datagrid displays
>> it the way I want. But my listbox just repeats the line
>> "system.data.datarowview" over and over.
>>
>> Any help is, as usual, appreciated.
>
>

Re: Noob question - binding data to list box (system.data.datarowview?)

am 18.04.2008 07:33:31 von Arch Stanton

Replies solved my problem. You guys rule.

-Grateful Noob :|



Lloyd Sheen wrote:
>
> "Arch Stanton" wrote in message
> news:zZCdnSmRF8Ka75rVnZ2dnUVZ_sWdnZ2d@comcast.com...
>> I'm trying to bind data in a dataset (obtained from an Access DB) to a
>> listbox in ASP.net. I know my dataset is being created properly
>> because it displays fine in a datagrid, but I can't get it to display
>> in a listbox. Here's what I'm trying:
>>
>> dgrDataGrid.DataSource = dstData.Tables("Manufacturer")
>> lstMake.datasource = dstData.Tables("Manufacturer")
>> Page.DataBind
>>
>> There is only one column in the dataset's table, and the datagrid
>> displays it the way I want. But my listbox just repeats the line
>> "system.data.datarowview" over and over.
>>
>> Any help is, as usual, appreciated.
>
> You need to tell the listbox what to display. The default is the
> .toString so you are getting the object type as each occurence.
>
> LS