Solved

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

Posted on 2014-12-19
3
413 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
  • 2
3 Comments
 
LVL 33

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now