Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-12-19
3
Medium Priority
?
481 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 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