473,325 Members | 2,342 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,325 software developers and data experts.

GridView Update Not Firing

42
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 3721
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
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...
7
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...
1
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
by: LearnMore.John | last post by:
Is it possible to update all the rows in a single postback using Gridview Control, regards John
2
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...
9
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...
2
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...
1
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...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.