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

GridView not Updating Through SqlDataSource

I have a very simple setup that should work fine per documentation. However,
my gridview control will not properly update using the updatecommand of the
sqldatasource. I've simplified everything below. I'd like to be able to see a
table of results in my gridview, click edit on any particular record, modify
the data, then click update. What I find is happening is that my parameters
are not being updated when I go into edit mode, change the text of the
"firstName" field, and click update. In the OnUpdating method of the
sqldatasource, I've stepped through the command parameters collection and it
always contains the original values, not what I've typed into the editable
textboxes in my grid.
<asp:GridView ID="gvContacts" PageSize="200" DataKeyNames="id"
CssClass="GridViewStyle" GridLines="both" AllowSorting="true" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
AllowPaging="True" Width="98%" Visible="true" >
<Columns>
<asp:BoundField DataField="firstName" HeaderText="First Name"
SortExpression="firstName" HeaderStyle-HorizontalAlign="center"
HeaderStyle-VerticalAlign="middle" >
</asp:BoundField>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
</Columns>

</asp:GridView>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
OldValuesParameterFormatString="original_{0}"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:MyConnectionString%>"
SelectCommand="SELECT id, firstName, lastName, email, phone, importance,
message, subscribeToNewsletter, howDidYouHearAboutUs, createdBy, dateCreated,
lastUpdateBy, lastUpdateDate FROM Contacts"SelectCommandType="text"
UpdateCommand = "UPDATE Contacts SET firstName=@firstName where
id=@original_id"
UpdateCommandType="text"
DeleteCommand="DELETE FROM Contacts WHERE id=@original_id"
DeleteCommandType="Text">
</asp:SqlDataSource>
--
PK9
Oct 12 '08 #1
0 1730

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

Similar topics

1
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
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...
3
by: adam222 | last post by:
hello, i have a web-form with a GridView control, i wanted to update & delete, using the AutoGenerateEditButton. when i used it with sqlDataSource (executing SP in the DB) it works like a...
1
by: MasterChief | last post by:
Is it possible to select an item on a gridview by clicking on it and then being able to click a link for example that says EditOrder in a treeview and have the EditOrder page open up viewing what...
5
by: Michael | last post by:
Hi Everyone, I've been having a problem with the Gridview control. I have posted a few messages relating to the issues, but I have a general question. Does the Dataview control have to be bound to...
4
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= | last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy just wanted easy UI to make updates. When I select ‘Edit’, I get the fields I want to edit. I edit them and click...
0
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ...
0
by: TheDebbis | last post by:
I'm making a quick CD catalog to help me learn ASP.NET (using C# primarily.) I have a number of gridview's on my site that are working properly, but for some reason, one is not updating or deleting....
2
by: xMetalDetectorx | last post by:
Hi Everyone, I have a very simple web app that uses .Net 2.0 login control to authenticate users and allow access to an "admin" folder. Inside that admin folder I have one page that has a...
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: 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
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...
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...

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.