Performance on requery of dropdown box populated by XML...

I've got a drop down box that I'm populating with a dataset from XML.

When I hit the drop down box the first time, it seems to populate lightning fast.

However, when I re-hit the drop down box (say I'm adding a second record), the performance slows down exponentially.

I'd be happy to post code if that'd help.

Thanks in advance.

Jason

[352 byte] By [JasonDeegan] at [2007-12-16]
# 1
Can you please post the code you are using.
It will help to detect what might be responsible for the degradation in performance.

Thanks.

MarkIhimoyan at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2

Thanks for the response!

Here's what I'm using - if there's a better way, I'm game.

Thanks again!!!!

Jason

CODE BELOW:
_

Private Sub loadAssetNames(ByVal store As String)

ds2.Clear()

strXMLFile2 = "\DR\DRAssets\Assets" & store & ".xml"

While System.IO.Directory.Exists(strAssetsDir) = False

System.IO.Directory.CreateDirectory(strAssetsDir)

End While

While System.IO.File.Exists(strXMLFile2) = False

System.IO.File.Copy("\DR\DRAssetSetup\AssetsTemplate.xml", strXMLFile2)

End While

Dim ConstraintText As String = "NOT ([name] IN ("

ds2.ReadXml(strXMLFile2)

For Each dr As DataRow In ds2.Tables(0).Rows()

If (dr.Item("AssetName") <> "Compressor" And dr.Item("AssetName") <> "") Then

ConstraintText = ConstraintText & "'" & dr.Item("AssetName") & "',"

End If

Next

ConstraintText = ConstraintText & "'' ))"

dsTypes.Clear()

dsTypes.ReadXml(typesXML)

dtTypes = dsTypes.Tables("type")

Dim TypesDV As New DataView(dsTypes.Tables("type"))

TypesDV.RowFilter = ConstraintText

With cbAN

.DataSource = TypesDV

.DisplayMember = "name"

.ValueMember = "name"

End With

End Sub

JasonDeegan at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3
Hi Jason,
I looked through your code and basically what happens is that for every time you add a record to the DataSet the combo box rebinds to the DataSource.
In other words the Combo box is rebound everytime the list changed event is fired by the underlying DataSource.
You should clear the Bindings on your combox box before you update the DataSource, then rebind when you are done with the update.

So what I would do will be to set cBaN.DataSource = nothing at the top of this function (just before you call ds2.Clear() or you can do this just before you call dsTypes.Clear()).

Then you should see an improvement in your performance.

MarkIhimoyan at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4
Thanks so much! I'll try it out. Tried it...works like a charm. Prish!

Jason

JasonDeegan at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...