473,396 Members | 1,703 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,396 software developers and data experts.

UpdateCommand not working - DatakeyNames is included

I have a Gridview connected to a SqlDataSource. The problem is that my UpdateCommand is not working after pressing the edit link, and then update link. I have AutoGenerateEditButton="True" set and DataKeyNames set to the primary key of my table. The code follows: The funny thing is that if I say ="Update vehicles SET manufacturer_id=?,model_id=?,asking_price=? WHERE vehicle_id=3", thus manually setting the vehicle_id=3 or for whatever row, it updates. But if I say vehicle_id=? in UpdateCommand nothing happens. No errors either. My AutoGenerateDeleteButton works 100% but no Edit

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="vehicle_id"
  2.             DataSourceID="SqlDataSource1" AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" >
  3.             <Columns>
  4.                 <asp:CommandField ShowSelectButton="True" />
  5.                 <asp:BoundField DataField="vehicle_id" HeaderText="vehicle_id" InsertVisible="False"
  6.                     ReadOnly="True" SortExpression="vehicle_id" />
  7.                 <asp:BoundField DataField="manufacturer_id" HeaderText="manufacturer_id" SortExpression="manufacturer_id" />
  8.                 <asp:BoundField DataField="model_id" HeaderText="model_id" SortExpression="model_id" />
  9.                 <asp:BoundField DataField="vehicle_cat_id" HeaderText="vehicle_cat_id" SortExpression="vehicle_cat_id" />
  10.                 <asp:BoundField DataField="asking_price" HeaderText="asking_price" SortExpression="asking_price" />
  11.                 <asp:BoundField DataField="current_mileage" HeaderText="current_mileage" SortExpression="current_mileage" />
  12.             </Columns>
  13.  
  14.         </asp:GridView>
  15.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="dsn=FSW"
  16.             ProviderName="System.Data.Odbc" SelectCommand="SELECT * FROM [vehicles]"
  17.             UpdateCommand="Update vehicles SET manufacturer_id=?,model_id=?,asking_price=? WHERE vehicle_id=?"
  18.             DeleteCommand="Delete from vehicles where vehicle_id=?"
  19.             OnUpdated="OnDSUpdatedHandler"></asp:SqlDataSource>
Any help would be appreciated
Thanks
Nov 19 '10 #1
0 1079

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Lee Moore | last post by:
I have the following code, which I thought should work. I get an error stating ... Could not find control 'GOAL_TEXT_CONTROL' in ControlParameter 'GOAL_TEXT'. Any help would be great. ...
9
by: whaletyr | last post by:
When I try to update an access database using the commandbuilder and updatecommand. I get the An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll ...
1
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the...
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
1
by: jkeel | last post by:
Is it possible to use a stored procedure instead of a SQL statement with the update command on a detail view in asp.net 2005. If so, how?? I can't seem to pass parameters into the stored...
1
by: Dan Sikorsky | last post by:
Environment: VS2005, C#, SQLServer 2005 Error Message: Object Must Implement IConvertible I'm using a FormView whose DataSourceID = SqlDataSource1 SqlDataSource1 has an update command whose...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
1
by: David C | last post by:
I have aspx web page with a GridView that displays data from a SqlDataSource view that combines 2 tables to show information. It has an Edit feature and the SqlDataSource has an UpdateCommand text...
2
by: rgparkins | last post by:
So, I've bitten the bullet and am converting some of my asp.net 1.1 sites to asp.net 2.0, now after many issues I have come to a stop with the objectdatasource and gridviews and maybe someone can...
5
by: somacore | last post by:
I have a C# webform which uses a formview to insert, update, and delete records selected from a gridview into an Access database. The insert and delete functions work fine, the update does not. ...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.