Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / February 2004

Tip: Looking for answers? Try searching our database.

DataKeys(Index): Scope issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee C. - 27 Feb 2004 09:56 GMT
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 - 27 Feb 2004 20:17 GMT
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

> 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
[quoted text clipped - 12 lines]
> Thanks,
> Lee

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.