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

Home Posts Topics Members FAQ

GridView Update Not Firing

42 New Member
I am working porting ugly .NET 1.1 DataGrids to 2.0 GridViews. The GridView fills correctly via SqlDataSource. When I click Edit -> [make a field change] -> Update, the page refreshes but the update command clearly never fired. (Putting stuff in the GridView's OnRowUpdating function proves this.) The row also remains in edit mode.

The code:

Expand|Select|Wrap|Line Numbers
  1. <asp:SqlDataSource ID="dsMyReports" runat="server" 
  2.                 ConnectionString="<%$ ConnectionStrings:vortex2devConnectionString %>"
  3.                 SelectCommand="SELECT [ID], [Name], [Description] FROM [Report] WHERE (([IsPublic] = @IsPublic) AND ([OwnedByUserID] = @userID))" 
  4.                 OnSelecting="dsMyReports_Selecting" 
  5.                 DeleteCommand="DELETE FROM Report WHERE ID = @reportID" 
  6.                 UpdateCommand="UPDATE Report SET Name = @Name, Description = @Description WHERE ID = @ID">
  7.         <SelectParameters>
  8.             <asp:Parameter DefaultValue="0" Name="IsPublic" Type="Int32" />
  9.             <asp:Parameter DefaultValue="" Name="userID" Type="Int32" />
  10.         </SelectParameters>
  11.         <DeleteParameters>
  12.             <asp:Parameter Name="reportID" />
  13.         </DeleteParameters>
  14.         <UpdateParameters>
  15.             <asp:Parameter Name="Name" />
  16.             <asp:Parameter Name="Description" />
  17.             <asp:Parameter Name="ID" />
  18.         </UpdateParameters>
  19.     </asp:SqlDataSource>
  20.  
  21.     <asp:GridView ID="myReportsGrid" runat="server" AutoGenerateColumns="False" DataSourceID="dsMyReports" DataKeyNames="ID">
  22.         <Columns>
  23.             <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
  24.             <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
  25.             <asp:CommandField ControlStyle-Width="16px" ButtonType="Image" EditImageUrl="~/images/edit_icon2.gif" ShowEditButton="true" />
  26.         </Columns>
  27.     </asp:GridView>
Thanks!
Feb 18 '09 #1
1 3738
bhupinder
32 New Member
We can update easily using sqldatasource
but you have to pass parameters same name of the column

like langid=@langid if we change,
langid=@id it will not work its better you must use rowediting event rather than
sqldatasource
Expand|Select|Wrap|Line Numbers
  1.  <asp:GridView ID="gvdata" runat="server" AutoGenerateColumns="False" DataKeyNames="locationID"
  2.         DataSourceID="SqlDataSource1">
  3.         <Columns>
  4.             <asp:CommandField ShowEditButton="True" />
  5.             <asp:BoundField DataField="locationID" HeaderText="locationID" InsertVisible="False"
  6.                 ReadOnly="True" SortExpression="locationID" />
  7.             <asp:BoundField DataField="locationName" HeaderText="locationName" SortExpression="locationName" />
  8.             <asp:BoundField DataField="langID" HeaderText="langID" SortExpression="langID" />
  9.         </Columns>
  10.     </asp:GridView>
  11.     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MWCConnectionString %>"
  12.         SelectCommand="SELECT [locationID], [locationName], [langID] FROM [tbl_locationInfo]"
  13.         UpdateCommand="update tbl_locationinfo set locationName=@locationName ,langID=@langID where locationid=@locationid">
  14.         <UpdateParameters>
  15.             <asp:Parameter Name="locationName" />
  16.             <asp:Parameter Name="langID" />
  17.             <asp:Parameter Name="locationid" />
  18.         </UpdateParameters>
  19.     </asp:SqlDataSource>
Feb 27 '09 #2

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

Similar topics

0
7812
by: Stephen | last post by:
My primary GridView is firing an OnDataBound after Selecting a row (which triggers SelectedIndexChanged). This only happens in the following scenario: - User enters a textbox search value and hits "GO" - Gridview is filled with results (4 grids in all, only the "primary" is filled at this point) - User Selects a row from the gridview. - User clicks an "Add" button which calls a javascript window.showmodaldialog
7
5475
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when looping through the GridView, it doesn't
1
2729
by: Alex A. | last post by:
I've got an unbound gridview that I'm late binding. The RowUpdating isn't firing when the gridview's update button is clicked. What am I missing? Thanks
2
2311
by: LearnMore.John | last post by:
Is it possible to update all the rows in a single postback using Gridview Control, regards John
2
2446
by: | last post by:
I want to know how to make a clickable button or Command field on a GridView, and have the user's action a) fire a function and b) pass a data value from one of the GridView's columns to that function. Long version: ASP.NET's usual paradigm with master-detail editing is to have you define a commandfield, and on your detail view to define a second datasource that uses the SelectedValue of the GridView to determine what the detail record...
9
26928
by: John007 | last post by:
I am using a SQLDataSource to populate my gridview in ASP.Net 2.0. When I hit Edit, the textboxes appear and I am able to edit my values. When I hit Update, the changes are not saved, and there is no error message. I put a breakpoint on the RowUpdating event handler and found that the event is not fired. Right now, I have not written code for the Update event. I am just wondering why the event is not firing. Here Person_ID is the primary key....
2
11041
by: John007 | last post by:
I am using a GridView in ASP.Net 2.0 to Insert, Edit, Update and Delete. I am using ItemTemplate and EditItemTemplate and the buttons are LinkButtons. I am inserting a new row from the footer. The RowCommand event is firing twice when I hit the Edit, Update, Delete and Insert buttons. The AutoEventWireup is set to false. What am I missing? Thanks.
1
2300
by: koren99 | last post by:
Hello, I have a gridview that is filled with a datasource & template fields dynamically. ( that has to be done because i ask the user for a datasource) anyway, i started out creating a static but empty grid. and added the template controls and datasource & activated grid.DataBind() in the page_load event. that gave me all the info when the page loaded on screen. now i have an edit and update buttons on each row and pressing the...
11
6070
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 if that's what's causing the behavior or not. It seems like the Update button should at least do something. When the Edit button is clicked, the grid goes into Edit mode and the Cancel button takes the grid out of Edit mode. So, I don't get what...
0
9685
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
10465
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10200
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
9061
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...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5453
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...
1
4127
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
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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.