DataList.DataKeys problem

  • Thread starter Thread starter Marina
  • Start date Start date
M

Marina

Hi,

There is a component that is binding the results of a search to a DataList.
By clicking on an image in the datalist, the user can download that
particular item. We are using the DataKeys property to retrieve the ID (as
stored in the database), to then locate the item, and do some other stuff
and push the file out to the user.

The first time the search is performed, the user can download the file, and
the correct file gets downloaded. Let's say there were 10 results

However, the second time the search is done (different criteria), let's say
there were 20 results. Now, the first 10 results, the DataKeys property
returns the ID from the *first* search. For the last 10, the results are
correct.

So it seems the DataKeys property is not getting updated with the new
results, even though a new DataBind is taking place. So all the "extra"
rows, have a new entry in the DataKeys property, and this is correct. But
the first X rows, where X is the number of rows in the first result set, do
not.

Can anyone shed any light on this?
 
I don't think that's really necessary given the description, but here:

Sub DataList_ItemCommand(ByVal sender As Object, ByVal e As
DataListCommandEventArgs)
SendFile(MyList1.DataKeys(e.Item.ItemIndex))
End Sub

SendFile, just uses the key to look up the path of the file and then sends
it.
 
Does that matter what the databind is? The item template being used is not
relevant to the DataKeys property and how that is being populated. If there
are 5 dropdown and 8 labels, or just one checkbox in each item list, the
DataKeys property is being populated exactly the same way regardless.

The databinding code itself, is just:

MyList1.DataSource = GetDataSource()
MyList1.DataBind()

Where GetDataSource just returns a table with the results of the query.

Again, the databinding code is pretty much the only way you can databind, so
I don't think it is helpful.
 
C'mon Marina,

maybe the young Cristian needs only in wich sub or
function the datagrid databind happens.....
Is it too hard to find?

C'mon Marina

theDude
 
Back
Top