?
Solved

How run custom update code in gridview?

Posted on 2008-11-18
1
Medium Priority
?
416 Views
Last Modified: 2012-06-21
I have a gridview with several fields.  The user should be able to click 'edit', update several fields, then click 'update'.  I want to run CUSTOM code for the update command.  

How can I do this?  I suppose I would check the e.commandname in the rowcommand event, but I don't know how to access the controls that contains the new values.

Any code samples?

Thanks.
0
Comment
Question by:RobertNZana
1 Comment
 
LVL 2

Accepted Solution

by:
jacksonm1234 earned 300 total points
ID: 22989766
Howdy Robert.

Try using the rowUpdating event of the gridview.  Use 'e.rowindex' and the findcontrol method to access the controls. See snippet below. I hope it helps!


Protected Sub grdMyPicks_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles grdMyPicks.RowUpdating
        If Page.IsValid Then
            Dim winner As String = CType(grdMyPicks.Rows(e.RowIndex).FindControl("ddlEditwinner"), DropDownList).SelectedValue
            SqlDataSource1.UpdateParameters("W_Team").DefaultValue = winner
            SqlDataSource1.Update()
 
        End If
 
    End Sub

Open in new window

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

807 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