PC Review


Reply
Thread Tools Rate Thread

databound listbox question

 
 
joe
Guest
Posts: n/a
 
      22nd Nov 2004
I actually have 2 questions:

1) Is databinding the fastest way to load a listbox from sqlserver?
speed is crucial and I want to make sure i'm populating it the fastest
way i can

2) Also, i'm having trouble getting the selected items in the
listbox.

Will simply using the Items property (with the index) not give me
access to the value?:

For intIndex = lstStatus.SelectedIndex To lstStatus.Items.Count - 1
strTest = strTest & lstStatus.Items(intIndex)
Next

what's so frustrating is that i'm actually doing this for Excel using
VSTO and everytime i try to use the .Items(intIndex) - Excel
completely crashes on me.

anybody point me to an example or hint?

TIA!
Joe


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      23rd Nov 2004
Joe,
>
> 1) Is databinding the fastest way to load a listbox from sqlserver?
> speed is crucial and I want to make sure i'm populating it the fastest
> way i can


The time done with reading the rows accoording with the question what
loading of the listbox is the fastest is comparing parts of seconds with
parts of milliseconds.

>
> 2) Also, i'm having trouble getting the selected items in the
> listbox.
>
> Will simply using the Items property (with the index) not give me
> access to the value?:
>
> For intIndex = lstStatus.SelectedIndex To lstStatus.Items.Count - 1
> strTest = strTest & lstStatus.Items(intIndex)
> Next
>

Do you have Option Strict On in top of your program?

Probably you only have to add ".ToString" after that (intIndex)

I hope this helps?

Cor


 
Reply With Quote
 
joe
Guest
Posts: n/a
 
      23rd Nov 2004
Cor-
Thank you very much! The .ToString is definitely a step in the right
direction as it's at least keeping Excel from crashing on me, but i'm
still having one problem.

When I use the .ToString, i'm returned "System.Data.DataRowView" so
i'm assuming it's because it's databound and I must somehow use a
datarowview object to access the value?

any help would be appreciated-

thanks-
joe



On Tue, 23 Nov 2004 09:55:00 +0100, "Cor Ligthert"
<(E-Mail Removed)> wrote:

>Joe,
>>
>> 1) Is databinding the fastest way to load a listbox from sqlserver?
>> speed is crucial and I want to make sure i'm populating it the fastest
>> way i can

>
>The time done with reading the rows accoording with the question what
>loading of the listbox is the fastest is comparing parts of seconds with
>parts of milliseconds.
>
>>
>> 2) Also, i'm having trouble getting the selected items in the
>> listbox.
>>
>> Will simply using the Items property (with the index) not give me
>> access to the value?:
>>
>> For intIndex = lstStatus.SelectedIndex To lstStatus.Items.Count - 1
>> strTest = strTest & lstStatus.Items(intIndex)
>> Next
>>

>Do you have Option Strict On in top of your program?
>
>Probably you only have to add ".ToString" after that (intIndex)
>
>I hope this helps?
>
>Cor
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      24th Nov 2004
Joe,

I think that my thought was that because you where asking it, you had not
binded data to the listbox yet.
and that as well because you where using the item.

Probably because when you use a datasource that is taken for an operation as
you do.

However to keep it in the way you did, this did work for me as well.

\\\
strTest = strTest & DirectCast(ListBox1.Items(intIndex),
DataRowView)("Name").ToString
///
("Name" is the used datamember so that you have to change for yours)

While I had expect something as
\\\
strTest = strTest & DirectCast(ListBox1.DataSource,
DataView)(intIndex)("Name").ToString
///
What works as well. For "DirectCast(ListBox1.DataSource, DataView)" you can
directly place the datasource.

I hope it helps?

Cor

"joe" <(E-Mail Removed)>

> Thank you very much! The .ToString is definitely a step in the right
> direction as it's at least keeping Excel from crashing on me, but i'm
> still having one problem.
>
> When I use the .ToString, i'm returned "System.Data.DataRowView" so
> i'm assuming it's because it's databound and I must somehow use a
> datarowview object to access the value?
>
> any help would be appreciated-
>
> thanks-
> joe
>
>
>
> On Tue, 23 Nov 2004 09:55:00 +0100, "Cor Ligthert"
> <(E-Mail Removed)> wrote:
>
>>Joe,
>>>
>>> 1) Is databinding the fastest way to load a listbox from sqlserver?
>>> speed is crucial and I want to make sure i'm populating it the fastest
>>> way i can

>>
>>The time done with reading the rows accoording with the question what
>>loading of the listbox is the fastest is comparing parts of seconds with
>>parts of milliseconds.
>>
>>>
>>> 2) Also, i'm having trouble getting the selected items in the
>>> listbox.
>>>
>>> Will simply using the Items property (with the index) not give me
>>> access to the value?:
>>>
>>> For intIndex = lstStatus.SelectedIndex To lstStatus.Items.Count - 1
>>> strTest = strTest & lstStatus.Items(intIndex)
>>> Next
>>>

>>Do you have Option Strict On in top of your program?
>>
>>Probably you only have to add ".ToString" after that (intIndex)
>>
>>I hope this helps?
>>
>>Cor
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with databound listbox. Ken Varn Microsoft ASP .NET 0 12th Nov 2004 01:33 PM
Moving items in databound ListBox? =?Utf-8?B?Sm9iIExvdA==?= Microsoft Dot NET 3 18th Aug 2004 09:46 AM
Re: DataBound ListBox gerrod Microsoft ASP .NET 1 5th Jul 2003 05:58 PM
Re: DataBound ListBox Gerrod Thomas Microsoft ASP .NET 0 3rd Jul 2003 10:48 AM
DataBound ListBox anastasia Microsoft ASP .NET 2 3rd Jul 2003 05:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 PM.