473,796 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual C# Webform - FormView Update Not Working

24 New Member
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.
  • The formview has 'id' as a DataKeyName.
  • The update works if done from the Query Builder and I enter the values manually
  • I don't have anything in the codebehind for the update event.

UpdateCommand:
Expand|Select|Wrap|Line Numbers
  1. UpdateCommand=
  2. "UPDATE CM_Codebase 
  3. SET 
  4. build_label = ?
  5. , program_type = ?
  6. , program_name = ?
  7. , ticket_status = ?
  8. , push_number = ?
  9. , approved = ?
  10. , comments = ? 
  11. WHERE 
  12. (id = ?)"
UpdateParameter s:
Expand|Select|Wrap|Line Numbers
  1. <UpdateParameters>
  2.             <asp:Parameter Name="build_label" />
  3.             <asp:Parameter Name="program_type" />
  4.             <asp:Parameter Name="program_name" />
  5.             <asp:Parameter Name="ticket_status" />
  6.             <asp:Parameter Name="push_number" />
  7.             <asp:Parameter Name="approved" />
  8.             <asp:Parameter Name="comments" />
  9.             <asp:Parameter Name="id"  />
  10.         </UpdateParameters>
FormView Definition:
Expand|Select|Wrap|Line Numbers
  1. <asp:FormView ID="FormView1" 
  2. runat="server" BackColor="LightGoldenrodYellow" 
  3. BorderColor="Tan" BorderWidth="1px" 
  4. CellPadding="2" DataKeyNames="id" 
  5. DataMember="DefaultView" DataSourceID="AccessDataSource1" 
  6. ForeColor="Black" HorizontalAlign="Center">
  7. <FooterStyle BackColor="Tan" />
  8.  
Update Button:
Expand|Select|Wrap|Line Numbers
  1. <asp:LinkButton ID="UpdateButton" 
  2. runat="server" CausesValidation="True" 
  3. CommandName="Update" 
  4. Text="Update">
  5.  
Any help is appreciated.
Dec 5 '08 #1
5 7038
Plater
7,872 Recognized Expert Expert
What error message are you getting?
If you are not getting an error at all, it usually means that it found no record to update.
Dec 5 '08 #2
somacore
24 New Member
I'm not getting an error. The command proceeds as normal, like it's actually updating, then the page does the postback and everything is the same.

I've added some code to debug it...

Expand|Select|Wrap|Line Numbers
  1. protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
  2.     {
  3.         object comments = e.OldValues["comments"];
  4.         object newcomment = e.NewValues["comments"];
  5.     }
Now, looking at the Autos debug window I see that it's getting the new value for the "comments" field, I changed the value to "BYZANTINE" just so it would stick out. The old value was "WHAT"

So, when I update the field and click the Update link button, it's getting the new value but for some reason not storing it.

What to do...

edit: Also, it's getting the key "id" just fine with its value of "10" so I'm not sure what to check next...

Edit again: Is there any way to see the SQL statement it's trying to use? If I just write out the update command it's giving me all the "?"'s but what I want to see are my variables in there.
Dec 5 '08 #3
Plater
7,872 Recognized Expert Expert
Hmm, I don't normally do data processing in the design section.
Nothing happens in your page load that populates or clears these values right?
You don't need to do any checking for isPostBack ?
Dec 5 '08 #4
Filip Baeke
2 New Member
I'm having exactly the same problem as Somacore.
Did you find a solution ?
Sep 8 '10 #5
Filip Baeke
2 New Member
I removed ConflictDetecti on="CompareAllV alues" in my SQLdatasource and now it works fine !
Sep 9 '10 #6

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

Similar topics

8
6209
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2178925" This is beacuse some of my TextBoxes are empty (no value). If I enter a value it is OK. I need to use Null values to indicate that the field is not fileld in.
3
3879
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a GridView control, each with its own SqlDataSource. FormView1 talks to my Opportunity table and has an ItemTemplate and an EditItemTemplate. FormView2 talks to my Activities table and has an ItemTemplate, InsertItemTemplate and an...
3
6044
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
0
2494
by: sdash | last post by:
I'm working on a simple formview screen that should update a SQL Server 2000 record. I'm sure there must be something simple wrong, but when I press update, the screen refreshes and the changes are not committed to the table. Can anyone give me some suggestions here? Thanks in advance (code below) <%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditItem.aspx.cs" Inherits="EditItem" %>
3
3434
by: Jurgen Appelo | last post by:
I asked this question earlier, but unfortunately the two replies I got did not solve the problem. Here it is again, but now with the code: After an Update my FormView always loses its viewstate values. The field values in the FormView are always overwritten by the results of the Update method in the business layer. No matter what I do, the databind always takes place, even when I don't want it to. See the example below. This is a...
2
2028
by: Dabbler | last post by:
I have a FormView with lots of field that have validators attached but none of them are working. Most are RequiredFieldValidtors, some are Regex etc. here's some of my code: <asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit" DataKeyNames="RegistrantId" DataSourceID="odsRegistrant" CssClass="waFormView" > ...... <EditItemTemplate> <asp:TextBox ID="tbWArrival" Text='<%# Bind("WArrival")
3
3642
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText" runat="server"></asp:Label></td> <td> <asp:TextBox ID="tbResponseText" runat="server" Text='<%#
3
8108
by: KaOne | last post by:
Hi All, excuse me in advance for my not very perfect english. I need some help about a problem with a FormView bounded to an ObjectDataSource. In practise I have an ObjectDataSource that uses some BLL methods that implements the optimistic concurrency by a TimeStamp field into the DB. So, when I execute an insert, update or delete query if I receive 0 like return value from that queries I understand that a concurrency problem is occurs so...
4
8565
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that when it displays it shows values from the database and i have a link button edit on the ItemTemplate that changes the mode to edit mode and allows to edit the values which can be edited...
0
9679
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.