DataKeys(Index): Scope issue

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default DataKeys(Index): Scope issue

    I can access the dg's DataKeys values (table primary key values) from
    events raised by objects outside of the dg. For example, from a
    Button1_Click, where the button is not in the dg, but elsewhere on the
    page. I cannot access the dg's DataKeys values from events raised by
    objects inside of the dg (Edit button, Delete button, etc.), which is
    where I really need to. I get, "Index was out of range. Must be
    non-negative and less than the size of the collection. Parameter name:
    index". I am hard coding the index, for now, and that doesn't help.

    If I check the DataGrid1.DataKeys.Count, logically, from events raised
    within the dg, Count = 0, and from outside the dg, Count = 6.

    I just don't get this. Can someone please explain?

    Thanks,
    Lee
    Lee C. Guest

  2. Similar Questions and Discussions

    1. cflogin scope issue
      First of all I'd like to thank everyone in advanced for any help on the matter, I have a problam with the cflogin scope and the...
    2. CFC in Application Scope Looping Index
      I am getting an 'outofbounds' errors in cfc's that I have in application scope. This occurs in loops and is logically impossible to happen. Can...
    3. DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds
      Folks, Can someone please explan why this this line of code works fine when executed within an ItemCommand (that is, once the data are fully...
    4. [PHP] global scope issue
      does it matter if a global command has bee issued before with vars other than the $test var? i.e before the include if there is a global $somevar;...
    5. global scope issue
      "Shawn McKenzie" <nospam@mckenzies.net> wrote in message news:20030813142705.28520.qmail@pb1.pair.com... the As far as I know, no defined variable...
  3. #2

    Default Re: DataKeys(Index): Scope issue

    I solved it. The problem was not specific to the DataKeys. The problem was
    that the code in all of my ItemCommand events fires everytime any one of
    them fires. I guess I am mixing two samples, found on the Web, that don't
    mix so well, but I got it sorted out.

    The datagrid has built-in methods for handling record edits, updates,
    cancels, and deletes, but not inserts. So, I had to use the generic
    OnItemCommand which fires all aforementioned methods. That's the part I
    wasn't getting before, but now I see what's happening.

    , Lee


    "Lee C." <cichanowicz_l@hotmail.com> wrote in message
    news:c4bb3244.0402270156.8469b34@posting.google.co m...
    > I can access the dg's DataKeys values (table primary key values) from
    > events raised by objects outside of the dg. For example, from a
    > Button1_Click, where the button is not in the dg, but elsewhere on the
    > page. I cannot access the dg's DataKeys values from events raised by
    > objects inside of the dg (Edit button, Delete button, etc.), which is
    > where I really need to. I get, "Index was out of range. Must be
    > non-negative and less than the size of the collection. Parameter name:
    > index". I am hard coding the index, for now, and that doesn't help.
    >
    > If I check the DataGrid1.DataKeys.Count, logically, from events raised
    > within the dg, Count = 0, and from outside the dg, Count = 6.
    >
    > I just don't get this. Can someone please explain?
    >
    > Thanks,
    > Lee

    Lee Cichanowicz 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