DataList.DataKeys problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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?


    Marina Guest

  2. Similar Questions and Discussions

    1. Problem with ItemDAtaBound event of datalist
      I have a datalist that displays the following when a web page is rendered: Community_Property: 2 | Corporation: 5 | Custodian: 10 | Individual:...
    2. DataList Problem???hurry for help!!!
      I insert a DataList and a Datagrid in a page: <asp:DataGrid id="DataGrid1" style="Z-INDEX: 103; LEFT: 456px; POSITION: absolute; TOP:...
    3. Problem with DataGrid inside a DataList
      Hi. I have a problem regarding to the DataGrid_ItemDataBound event. I cant run this event when my datagrid is inside a DataList. The...
    4. DataList Problem
      I have a datalist that I subclassed and it has a usercontrol in the header template, in the usercontrol is a databound dropdown. It loads fine and...
    5. DataKeys in Datagrid
      I have a datagrid with a checkbox as one of the column. When the checkboxes are selected and a delete button at the bottom of the grid is clicked,...
  3. #2

    Default Re: DataList.DataKeys problem

    Do you have a code snippet I can take a look at?

    /Cristian

    "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    news:ukptMqGTDHA.560@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?
    >
    >

    Cristian Suazo Guest

  4. #3

    Default Re: DataList.DataKeys problem

    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" <crillus7@hotmail.com> wrote in message
    news:ernRU1GTDHA.2020@TK2MSFTNGP11.phx.gbl...
    > Do you have a code snippet I can take a look at?
    >
    > /Cristian
    >
    > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > news:ukptMqGTDHA.560@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?
    > >
    > >
    >
    >

    Marina Guest

  5. #4

    Default Re: DataList.DataKeys problem

    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" <crillus7@hotmail.com> wrote in message
    news:O7JhABHTDHA.1912@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" <zlatkinam@nospam.hotmail.com> wrote in message
    > news:ONqe13GTDHA.1912@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" <crillus7@hotmail.com> wrote in message
    > > news:ernRU1GTDHA.2020@TK2MSFTNGP11.phx.gbl...
    > > > Do you have a code snippet I can take a look at?
    > > >
    > > > /Cristian
    > > >
    > > > "Marina" <zlatkinam@nospam.hotmail.com> wrote in message
    > > > news:ukptMqGTDHA.560@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?
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Marina Guest

  6. #5

    Default Re: DataList.DataKeys problem

    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 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" <crillus7@hotmail.com> wrote in message
    >news:O7JhABHTDHA.1912@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" <zlatkinam@nospam.hotmail.com> wrote in message
    >> news:ONqe13GTDHA.1912@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" <crillus7@hotmail.com> wrote in
    message
    >> > news:ernRU1GTDHA.2020@TK2MSFTNGP11.phx.gbl...
    >> > > Do you have a code snippet I can take a look at?
    >> > >
    >> > > /Cristian
    >> > >
    >> > > "Marina" <zlatkinam@nospam.hotmail.com> wrote in
    message
    >> > > news:ukptMqGTDHA.560@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?
    >> > > >
    >> > > >
    >> > >
    >> > >
    >> >
    >> >
    >>
    >>
    >
    >
    >.
    >
    the Dude Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139