473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataList.DataKeys problem

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?
Nov 17 '05 #1
4 5342
Do you have a code snippet I can take a look at?

/Cristian

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:uk*************@TK2MSFTNGP10.phx.gbl...
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?

Nov 17 '05 #2
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.

"Cristian Suazo" <cr******@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP11.phx.gbl...
Do you have a code snippet I can take a look at?

/Cristian

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:uk*************@TK2MSFTNGP10.phx.gbl...
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?


Nov 17 '05 #3
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.

"Cristian Suazo" <cr******@hotmail.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
I understood the description you gave, that was not the issue. I mean that I would like to see when the datagrid is called and so on get an overview of
whats happening... I understand the ItemCommand event, I am more interesten in seeing when you databind and so on....

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP12.phx.gbl...
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.

"Cristian Suazo" <cr******@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP11.phx.gbl...
Do you have a code snippet I can take a look at?

/Cristian

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:uk*************@TK2MSFTNGP10.phx.gbl...
> 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?
>
>



Nov 17 '05 #4
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
-----Original Message-----
Does that matter what the databind is? The item template being used is notrelevant to the DataKeys property and how that is being populated. If thereare 5 dropdown and 8 labels, or just one checkbox in each item list, theDataKeys 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, soI don't think it is helpful.

"Cristian Suazo" <cr******@hotmail.com> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
I understood the description you gave, that was not the issue. I mean that
I
would like to see when the datagrid is called and so on get an overview of whats happening... I understand the ItemCommand event, I am more
interesten
in seeing when you databind and so on....

"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP12.phx.gbl...
> 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.
>
> "Cristian Suazo" <cr******@hotmail.com> wrote in
message > news:er**************@TK2MSFTNGP11.phx.gbl...
> > Do you have a code snippet I can take a look at?
> >
> > /Cristian
> >
> > "Marina" <zl*******@nospam.hotmail.com> wrote in message > > news:uk*************@TK2MSFTNGP10.phx.gbl...
> > > 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 thenew > > > 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?
> > >
> > >
> >
> >
>
>


.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vjmehra | last post by:
I have a datalist within a datagrid and I am having trouble trying to get the update command working. I am only using the one for the datagrid, but this should also update the datalist, however...
4
by: jenn | last post by:
Hi Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid Dim str = MyDataGrid.Cell(0).tex I would like something like this Dim str =...
2
by: Bruno Piovan | last post by:
Hi, I have a datalist, this datalist has a label for each item called lblId, this label hold the ID of each item. I need to write a procedure that will use the value of the label of each item, I'm...
1
by: Adam Knight | last post by:
Hi all, I have two Datalists. One is nested within the HTML of another. What i need to do is determine the current item index of the parent datalist in the OnItemBound of the child. Public...
0
by: Isz | last post by:
PROBLEM: This problem is related to the postback and handling events correctly. BACKGROUND: I have a datalist which acts as a tabbes list with horizontal layout. This datalist is bound to a...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
2
by: cmay | last post by:
I am binding a List(Of T) to a DataList. In this case, T is a class Test, which has a property TestId. I am trying to use the DataKeyField with this <asp:DataList DataKeyField="TestId" ... ...
1
by: MikeB | last post by:
I have a datalist with 2 columns (RepeatColumns = 2) that displays photos. The photo url is based on a value in the Web.Config so I have to set the url on the databoud event. Although this work...
1
by: Nathan Sokalski | last post by:
I have a custom Control that I have made that contains a DataList. In either the ItemCommand or SelectedIndexChanged event I need to retrieve a value from the DataItem of the SelectedItem. I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.