?
Solved

How to handle edit event with custom code in gridview control?

Posted on 2014-12-19
3
Medium Priority
?
463 Views
Last Modified: 2015-01-05
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.
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 2000 total points
ID: 40510476
Can you post your code showing how gv update is being done?
0
 

Author Comment

by:lapucca
ID: 40511214
The collection,  List<UserPrincipal> is created and bind to the gridview at PageLoad event and if not PostBack.  
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.
0
 

Author Comment

by:lapucca
ID: 40511261
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.
0

Featured Post

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question