Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 5th, 2007, 11:35 PM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default GridView -- How do I do custom updates?

I have a gridview that specifies a method to run in a codebehind page via the OnRowUpdating attribute. When I execute this update, I can clearly see that my stored procedure is being called twice (I verified this using SQL Profiler). The first time it’s called, it is being executed via the code in my code-behind page. The second time it’s called, it’s being called “automatically” thru the asp.net built-in gridview functionality in asp.net, and I’m receiving the following error: Procedure or function usp_RenameFolder has too many arguments specified. The really annoying thing is that the first time my sproc is called (via the codebehind code), it’s working just fine, but I can’t find a way to “turn off” the second time it gets called (the “built in” way). I wish to somehow stop the sproc from being called a second time.

Here’s the pertinent parts of gridview. If you want to see the whole thing, please don’t hesitate to ask.

    <asp:GridView ID="gvRootFolders" runat="server" blah blah blah OnRowUpdating="gvRootFolders_RowUpdating">

        …Blah blah blah…

                    <asp:TextBox ID="FolderNameField" Text='<%# Bind("FolderName") %>'
                        runat="server" MaxLength="256" ValidationGroup="EditDelete">

        …blah blah blah…


Here’s the data source code:

    <asp:SqlDataSource ID="MyDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
        DeleteCommand="usp_DeleteRootFolder" DeleteCommandType="StoredProcedure" InsertCommand="usp_AddRootFolder"
        InsertCommandType="StoredProcedure" SelectCommand="usp_GetRootFolders"
        SelectCommandType="StoredProcedure" UpdateCommand="usp_RenameFolder"
            <asp:Parameter Name="FolderID" Type="Int32" />
            <asp:Parameter Name="OldFolderName" Type="string" />
            <asp:Parameter Name="NewFolderName" Type="string" />
            <asp:Parameter Name="ModifiedBy" Type="Int32" />

My “code behind” code works. It is a method called gvRootFolders_RowUpdating that creates a SQLConnection and executes the usp_RenameFolder stored procedure in exactly the way I want to execute it (i.e. there’s error handling using recordsets and return values).

My question is: How can I disable the “built-in” updating functionality, while still allowing my custom code-behind update code to run?

Things I have already tried:
1) Remove the UpdateCommand and UpdateCommandType attributes from the asp:SqlDataSource tag
a. Result: I receive the following error message when executing an update: Updating is not supported by data source 'DocCentral' unless UpdateCommand is specified.
2) Remove the <UpdateParameters> tag (and all of its child tags) altogether
a. Result: I receive the following error message when executing an update: Procedure or Function 'usp_RenameFolder' expects parameter '@OldFolderName', which was not supplied.


Reply With Quote
  #2 (permalink)  
Old November 16th, 2007, 03:26 PM
Registered User
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

By the way, a belated thank you for this. It works perfectly!
Reply With Quote
  #3 (permalink)  
Old January 3rd, 2008, 06:00 PM
Registered User
Join Date: Jan 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I noticed that this also happens when the CausesValidation attribute is set to false for the asp:CommandField in the gridview.

I removed it from the attributes in the aspx page and OnRowEditing stopped processing twice.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance Penalty for Custom Code Gridview Row B wirerider ASP.NET 2.0 Professional 0 April 5th, 2006 04:43 PM
Custom Postback and Gridview refresh wirerider ASP.NET 2.0 Basics 5 February 28th, 2006 04:33 PM
Gridview custom buttons wirerider ASP.NET 2.0 Basics 2 February 5th, 2006 02:49 PM
Custom GridView bmains ASP.NET 2.0 Basics 0 August 8th, 2005 03:06 PM
Custom GridView (maybe?) bmains ASP.NET 2.0 Basics 0 April 18th, 2005 09:48 AM

All times are GMT -4. The time now is 04:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.