M
Matthew.DelVecchio
hey gang,
ok so i experienced something that doesnt operate as i would have
expected. in a component i build up a ListItemCollection in function
..GetGalleries() like so:
Dim galleries As New System.Web.UI.WebControls.ListItemCollection
'loop & add to collection
Dim node As XmlNode
For Each node In galleryNodes
galleries.Add(New ListItem("sometext", "somevalue"))
Next
Return galleries
then, in my application i attempt to bind like so:
Dim galleries As ListItemCollection = im.GetGalleries(year)
ddlGallery.DataSource = galleries
ddlGallery.DataBind()
....now, you would think then, that the ddlGallery dropdownlist would
take the returned ListItemCollection and bind its list items to the
list. It does -- sort of.. it does, BUT it doesnt use the ".value"
porton of the returned ListItems ("somevalue"). instead, it just takes
the ".text" value of each ListItem ("sometext") and sticks that in both
the text AND the value of each item in ddlGallery. whaaaa?
clearly, the expected behavior would be for ddlGallery list control to
see that its getting a ListItemCollection as a datasource, and
intelligently bind it -- by using the existing .text and .value values
if of the collection's ListItems... after all, this isnt any ole
collection, it's a *ListItemCollection*...!
as a work around, i have to loop thru the returned collection and add
each individually, like so:
Dim galleries As ListItemCollection = im.GetGalleriesForYear(year)
Dim item As ListItem
For Each item In galleries
ddlGallery.Items.Add(item)
Next
thats pretty lame. can anyone comment on this?
thanks!
matt
ok so i experienced something that doesnt operate as i would have
expected. in a component i build up a ListItemCollection in function
..GetGalleries() like so:
Dim galleries As New System.Web.UI.WebControls.ListItemCollection
'loop & add to collection
Dim node As XmlNode
For Each node In galleryNodes
galleries.Add(New ListItem("sometext", "somevalue"))
Next
Return galleries
then, in my application i attempt to bind like so:
Dim galleries As ListItemCollection = im.GetGalleries(year)
ddlGallery.DataSource = galleries
ddlGallery.DataBind()
....now, you would think then, that the ddlGallery dropdownlist would
take the returned ListItemCollection and bind its list items to the
list. It does -- sort of.. it does, BUT it doesnt use the ".value"
porton of the returned ListItems ("somevalue"). instead, it just takes
the ".text" value of each ListItem ("sometext") and sticks that in both
the text AND the value of each item in ddlGallery. whaaaa?
clearly, the expected behavior would be for ddlGallery list control to
see that its getting a ListItemCollection as a datasource, and
intelligently bind it -- by using the existing .text and .value values
if of the collection's ListItems... after all, this isnt any ole
collection, it's a *ListItemCollection*...!
as a work around, i have to loop thru the returned collection and add
each individually, like so:
Dim galleries As ListItemCollection = im.GetGalleriesForYear(year)
Dim item As ListItem
For Each item In galleries
ddlGallery.Items.Add(item)
Next
thats pretty lame. can anyone comment on this?
thanks!
matt