lapucca
asked on
How to handle edit event with custom code in gridview control?
Hi, I'm using VS2012, C# and asp.net.
I have a collection, List<UserPrincipal>, that I use as a datasource and binded to the gridview, by code. In gridview control property I set generate Edit button. Since the data source is not from a dataset. How can I have my own code executed when user selects "Update" button in the grid?
Thank you.
I have a collection, List<UserPrincipal>, that I use as a datasource and binded to the gridview, by code. In gridview control property I set generate Edit button. Since the data source is not from a dataset. How can I have my own code executed when user selects "Update" button in the grid?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, I found this and that seems to be what I need. However, I'm not sure how to find the object UserPrincipal in the collection List<UserPrincipal> that is being updated. So in the event TaskGridView_RowUpdating of this article, it's any array. Let say I can get the key from userid column of the row that is being edited, how do I find it in the collection? Thank you.
ASKER
1. Do I need to persist this collection in a session variable so I can use it to update it later or since it's bind to gridview then I would somehow still have access to this data?
2. In my Asp.net book, it only show how to use the UpdateCommand to run sql update. I have custom C# code that I need to run to update to AD. I haven't written this code yet but basically this is what I need to do.
a. Get the Userid column data form the data gird or somehow retain which row and the userid of that row that the user is updating when they click the Edit button.
b. When user click the update button, I need to retrieve the UserPrincipal object in the collection that is being edited and update AD. (How do I retrieve this object from gridview or do I need to persist this in session?)
Thank you.