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="i d"
CssClass="GridV iewStyle" GridLines="both " AllowSorting="t rue" runat="server"
AutoGenerateCol umns="False" DataSourceID="S qlDataSource1"
AllowPaging="Tr ue" Width="98%" Visible="true" >
<Columns>
<asp:BoundFie ld DataField="firs tName" HeaderText="Fir st Name"
SortExpression= "firstName" HeaderStyle-HorizontalAlign ="center"
HeaderStyle-VerticalAlign=" middle" >
</asp:BoundField>
<asp:CommandFie ld ShowEditButton= "true" ShowDeleteButto n="true" />
</Columns>
</asp:GridView>
<asp:SqlDataSou rce
ID="SqlDataSour ce1"
runat="server"
OldValuesParame terFormatString ="original_{ 0}"
ProviderName="S ystem.Data.SqlC lient"
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnection String%>"
SelectCommand=" SELECT id, firstName, lastName, email, phone, importance,
message, subscribeToNews letter, howDidYouHearAb outUs, createdBy, dateCreated,
lastUpdateBy, lastUpdateDate FROM Contacts"Select CommandType="te xt"
UpdateCommand = "UPDATE Contacts SET firstName=@firs tName where
id=@original_id "
UpdateCommandTy pe="text"
DeleteCommand=" DELETE FROM Contacts WHERE id=@original_id "
DeleteCommandTy pe="Text">
</asp:SqlDataSour ce>
--
PK9 0 1736 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the applicable fields in the gridview to a
sqldatasource which in turn calls a sproc with the appropriate parameters and
data. Any ideas?
Thanks...
|
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 select, remember it, and
then use it in the update. It works just fine when I have full control of the
whole process.
I want to do the same for...
|
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 charm, but when i want to pass the data through the
application's layers (BL etc.), it did not work.
it seems that the 'AutoGenerateEditButton' is...
|
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 you selected
in the gridview? My EditOrder link is in a sitemap so I don't know if
it is possible becuase you would almost have to pass a variable to...
|
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 a datasource that also contains the
update/delete Sql statements? The resaon I ask is that I've done just about
all I can do and can't update the...
| |
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 ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the...
|
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 ParkingBay
CommandField Me Y dropdownlistvalue
CommandField You ...
|
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. I have the buttons for both visible, and when I click edit, the update fields show up properly, but once I click 'update' the table is back with it's...
|
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 SQLDataSource and a GridView control. I am using the GridView to test updating a very simple table in the database. The problem is, it will not Update the...
|
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...
|
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...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |