AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 to delete a row from database througgh gridview controls
Posted by sumit agarwal on  8/13/2007 6:50:41 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
i have problem to get id of item

Dim id As Integer = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Value)

m writing above code line to get id of item in rowdeleting command of gridview but i run it in browser & click on delete link there is a exception occured as

Server Error in '/WebSite4' Application.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

plz. help me........

Post Your Reply Post New Question

 Viewer's Reply
Add index to the Values
Answered By Moderator1 on 8/18/2007 11:46:24 PM
Please try like this.

GridView1.DataKeys[e.RowIndex].Values[0].ToString()
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Speech Technology Magazine
FierceDeveloper
When Good HTML Goes Bad: How You Can Protect Your Web Applications