Solved

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

Posted on 2014-12-19
3
439 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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