473,382 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Gridview Update Troubles

I have a gridview which is pulling data from a SqlDataSource, the
select command queries a view and the update command is a stored
procedure. I'm using a stored procedure because several tables need to
be updated based on the data in the gridview.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:slightsInventoryConnectionString %>"
SelectCommand="SELECT * FROM [vDetailsWithKeys]"
UpdateCommand="upd_Inventory" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Street" Type="String" />
<asp:Parameter Name="CrossStreet" Type="String" />
<asp:Parameter Name="PoleType" Type="Int32" />
<asp:Parameter Name="PoleLength" Type="Int32" />
<asp:Parameter Name="PolePaint" Type="Boolean" />
<asp:Parameter Name="PoleUse" Type="Int32" />
<asp:Parameter Name="Foundation" Type="Int32" />
<asp:Parameter Name="TransformerBase" Type="Boolean" />
<asp:Parameter Name="Metered" Type="Boolean" />
<asp:Parameter Name="PoleNumber" Type="String" />
<asp:Parameter Name="FixtureQty" Type="Int32" />
<asp:Parameter Name="Comments" Type="String" />
<asp:Parameter Name="Incomplete" Type="Boolean" />
<asp:Parameter Name="ServiceLength" Type="Int32" />
<asp:Parameter Name="NotOnMap" Type="Boolean" />
<asp:Parameter Name="NotInCity" Type="Boolean" />
<asp:Parameter Name="MapPoleNum" Type="String" />
<asp:Parameter Name="PoleID" Type="Int32" />
<asp:Parameter Name="LampType" Type="Int32" />
<asp:Parameter Name="Circuit" Type="Int32" />
<asp:Parameter Name="Service" Type="Int32" />
<asp:Parameter Name="FixtureType" Type="Int32" />
<asp:Parameter Name="FixtureManufacturer" Type="Int32"
/>
<asp:Parameter Name="SuspensionType" Type="Int32" />
</UpdateParameters>
The gridview has several columns which display a dropdownlist when in
edit mode. I have included a sample:
<asp:TemplateField HeaderText="PoleType"
SortExpression="PoleTypeDescription">
<EditItemTemplate>
<asp:DropDownList ID="ddlPoleType"
runat="server"
DataSourceID="sdsPoleType"
DataTextField="PoleTypeDescription"
DataValueField="PoleTypeID"
SelectedValue='<%# Bind("PoleTypeID") %>' >
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1"
runat="server"
Text='<%# Bind("PoleTypeDescription") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

Everything looks great until I hit the update button.The row converts
itself to edit mode perfectly and all the dropdownlists fill correctly
and have the correct selectedvalue. When I hit Update, I get an error
message that "Procedure or function upd_Inventory has too many
arguments specified". I looked at the contents of the update statement
using SqlProfiler and it seems that the gridview update command is
sending a parameter value to the stored procedure for every column in
the gridview. Several columns in the gridview (some hidden/some not)
hold key values or other fields that I don't need/want to update.
Furthermore, all the parameters representing the dropdownlist columns
had null values. So, I decided to try handling everything in the
codebehind (using the RowUpdating event handler), which seems to mostly
work, except that the gridview still tries to do the update as well.
So, I took out the update command from the SqlDataSource and now I get
an error message that says:"Updating is not supported by data source
'SqlDataSource1' unless UpdateCommand is specified"

I feel like a fool because all this is supposed to be "easy" but I've
been unable to make this work. Thanks in advance for your help.

Nov 16 '06 #1
0 4321

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
4
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
0
by: mesut | last post by:
Hi there, I've a question. I would like to create a global update button to update all changed records gridview. e.g. A gridview contains 5 columns an 2 of the columns can be updated by the...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.