Deleting record from Datagird with Delete Button
Hi All,
I hope you can help me out with the problem in my application. I have a datagrid with a DELETE button. The datagrid has the following columns: DELETE ProjectName
The DELETE column is a button column to delete records. The Projectname column is a Hyperlink column that redirects to another page. The Hyperlink column uses ProjectID as the URL Field. When DELETE button is clicked, I would want to get the ProjectID of the ProjectName being clicked. THis ProjectID will be used as a parameter of a stored proc to delete the record from the database. When I tried using the code below:
DeleteFromDatabase(dgrdUsers.DataKeys(CInt(e.Item. ItemIndex)))
DeleteFromDatabase is a function that requires ProjectID as parameter to delete a record from the database. I always get this error :
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
What's odd is, I have an application that uses the same solution and the code works. I dont know what's causing the eror in my new application. I even tried copying and including the form of the other application and put it in my current project. When I did that, the app also returns the same error. It's really weird! The form works in the older app, but when I copied it to the new app, the error "index was out of range....." was thrown!
Thanks in advance!!
|