473,776 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView Update not updating data

I have a GridView with a couple of TemplateFields. When I click the update
link the Gridview returns to display mode with no errors but the data from
bound text fields or dropdown list isn't updated in the table. I'm stumped
and any help would be appreciated.

Thanks much.

My GridView:

<asp:GridView ID="VanListGrid View" runat="server"
AutoGenerateDel eteButton="True " AutoGenerateEdi tButton="True"
CellPadding="3" GridLines="Hori zontal"
DataSourceID="s dsVans" DataKeyNames="V anId"
AutoGenerateCol umns="False" CssClass="waGri dView"
AllowPaging="Tr ue" ShowFooter="tru e"
HorizontalAlign ="Center">
<FooterStyle CssClass="waFoo terStyle" />
<RowStyle CssClass="waRow Style" />
<EmptyDataTempl ate>
<asp:HyperLin k ID="HyperLink1 " runat="server" CssClass="waLin k"
NavigateUrl="Va nDetail.aspx">N ew</asp:HyperLink>
The table is empty.</EmptyDataTempla te>
<SelectedRowSty le CssClass="waSel ectedRowStyle" />
<PagerStyle CssClass="waPag erStyle" HorizontalAlign ="Right" />
<HeaderStyle CssClass="waHea derStyle" />
<AlternatingRow Style CssClass="waAlt ernatingRowStyl e" />
<Columns>
<asp:BoundFie ld DataField="VanI d" ReadOnly="true"
HeaderText="Id" SortExpression= "VanId" />
<asp:BoundFie ld DataField="Vend orVanNo" HeaderText="Ven dor
Van#" SortExpression= "VendorVanN o" />
<asp:TemplateFi eld HeaderText="Ven dorCode" ItemStyle-Width="60">
<ItemTemplate >
<asp:literal ID="Literal1" runat="server" Text='<%#
Eval("VendorCod e") %>' />
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st ID="ddlVendors " runat="server"
DataSourceID="s dsVendors" DataTextField=" VendorCode"
DataValueField= "VendorCode " Width="80"
SelectedValue=' <%# Bind("VendorCod e") %>'>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateFie ld>
<asp:BoundFie ld DataField="Stat us" HeaderText="Sta tus"
SortExpression= "Status">
<ItemStyle Width="100" />
</asp:BoundField>
<asp:TemplateFi eld HeaderText="Act ive">
<ItemTemplate >
<asp:CheckBox ID="ActiveCheck Box" runat="server"
Checked='<%# Eval("Active") %>' CssClass="waChe ckBox" />
</ItemTemplate>
<EditItemTempla te>
<asp:CheckBox ID="ActiveCheck Box" runat="server"
Checked='<%# Bind("Active") %>' CssClass="waChe ckBox" />
</EditItemTemplat e>
</asp:TemplateFie ld>
<asp:BoundFie ld DataField="Star tDate" HeaderText="Sta rt"
SortExpression= "StartDate"
DataFormatStrin g="{0:d}" HtmlEncode="fal se" />
<asp:BoundFie ld DataField="EndD ate" HeaderText="End "
SortExpression= "EndDate" DataFormatStrin g="{0:d}" HtmlEncode="fal se" />
</Columns>
</asp:GridView>

My Primary Vendors table SQL data source

<asp:SqlDataSou rce ID="sdsVans" runat="server"
ProviderName="S ystem.Data.SqlC lient"
ConnectionStrin g="<%$ ConnectionStrin gs:myDB %>"
SelectCommand=" SELECT VanId, VendorVanNo, VendorCode, StartDate,
EndDate, Status, Active FROM dbo.Vans order by VanId"
UpdateCommand=" Update dbo.Vans set VendorVanNo=@Ve ndorVanNo,
VendorCode=@Ven dorCode, Status=@Status, Active=@Active, StartDate=@Star tDate,
EndDate=@EndDat e where VanId=@VanId"
DeleteCommand=" Delete from dbo.Vans where VanId=@VanId">
</asp:SqlDataSour ce>

DataSource for dropdownlist:
<asp:SqlDataSou rce ID="sdsVendors " runat="server"
ProviderName="S ystem.Data.SqlC lient"
ConnectionStrin g="<%$ ConnectionStrin gs:cobbcc %>"
SelectCommand=" SELECT VendorCode FROM dbo.Vendors order by VendorCode">
</asp:SqlDataSour ce>
Mar 22 '06 #1
6 2395
Doesn't look like you have an UpdateCommand set.

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 22 '06 #2
I am using this update command:
UpdateCommand=" Update dbo.Vans set VendorVanNo=@Ve ndorVanNo,
VendorCode=@Ven dorCode, Status=@Status, Active=@Active, StartDate=@Star tDate,
EndDate=@EndDat e where VanId=@VanId"

"ag******@gmail .com" wrote:
Doesn't look like you have an UpdateCommand set.

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 22 '06 #3

The delete method in your code uses the same WHERE condition as the Update.
If the update were not working, I would expect that the Delete would not work
either. Can you verify? If so, try defining an UpdateParameter s collection
where you typecast each parameter using the proper "Type" (use the other post
in which I explained to you the use of the UpdateParameter s) and try it again.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I am using this update command:
UpdateCommand=" Update dbo.Vans set VendorVanNo=@Ve ndorVanNo,
VendorCode=@Ven dorCode, Status=@Status, Active=@Active, StartDate=@Star tDate,
EndDate=@EndDat e where VanId=@VanId"

"ag******@gmail .com" wrote:
Doesn't look like you have an UpdateCommand set.

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 23 '06 #4
q
My mistake I misunderstood your question (and read your code wrong!)
What result are you looking for?

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 23 '06 #5

Thanks for your reply David. I was just lamenting the fact that the
UpdateCommand did nothing. No errors and no update in the table. I have since
gven up on editing with the GridView and instead use the SelectCommand to
redirect to antoher page with a DetailsView for the edit.

Spending too much time trying to fathom the mysteries of binding to
SqlDataSource and not enough time producing results ;)
"q" wrote:
My mistake I misunderstood your question (and read your code wrong!)
What result are you looking for?

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 23 '06 #6
Yes the DeleteCommand worked.

I have since given up on editing the table with the GridView and instead use
the SelectCommand to redirect to another page with a DetailsView for the edit.

From my posts I'm sure you can see I'm spending too much time trying to
fathom the mysteries of binding to SqlDataSource and not enough time
producing results, probably should have stuck with the old style of coding a
dataset/dataadapter solution as in ASP.NET v1 ;)

Thanks for your ongoing assistance.

"Phillip Williams" wrote:

The delete method in your code uses the same WHERE condition as the Update.
If the update were not working, I would expect that the Delete would not work
either. Can you verify? If so, try defining an UpdateParameter s collection
where you typecast each parameter using the proper "Type" (use the other post
in which I explained to you the use of the UpdateParameter s) and try it again.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
I am using this update command:
UpdateCommand=" Update dbo.Vans set VendorVanNo=@Ve ndorVanNo,
VendorCode=@Ven dorCode, Status=@Status, Active=@Active, StartDate=@Star tDate,
EndDate=@EndDat e where VanId=@VanId"

"ag******@gmail .com" wrote:
Doesn't look like you have an UpdateCommand set.

David Betz
WinFX Harmonics Blog
http://www.davidbetz.net/winfx/

Mar 23 '06 #7

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

Similar topics

3
6337
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
8
5041
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 my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
4
2617
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I re-format the updated row fields. I have looked at gridView.rowUpdated method, but cannot figure out how....
0
4350
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables need to be updated based on the data in the gridview. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:slightsInventoryConnectionString %>" SelectCommand="SELECT * FROM " UpdateCommand="upd_Inventory"...
3
10275
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data does not change, and in the updated and updating row events the newValues collections are empty!!! I've tried various other methods such as using an ObjectDataSource, but my ArrayList does not existing in a database until after the editing and...
1
1974
by: Japskunk | last post by:
I am having trouble updating a SQL table through the GridView "Auto" Enable Edit Feature... I am connecting to a SQL 2000 Server with a SQLDataSource I have created the Update Query in the Command and Parameter Editor setup when I created my SQLadapter, along with Select and Delete. Here is the Update Command: UPDATE TBLUPSData SET UPSModel = @original_UPSModel, UPSLocation = @original_UPSLocation, UPSDeviceAttached =...
4
8762
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 html code below. -- Thank-you, Barbara Alderton <body>
5
13290
by: Luqman | last post by:
I added new rows to the GridView with the following code. I am using SqlDataSource and Sql Server 2000 Northwind Database Customers table. Dim sqlarg As New DataSourceSelectArguments Dim dv As New System.Data.DataView dv = SqlDataSource1.Select(sqlarg)
11
6068
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
1279
by: BizWeb | last post by:
Hi, i am new to ASP.NET. I have write a very simple code to try the updating of the GridView but it is not updating the data. Below is the simple code that i have use. <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
9628
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
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10289
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...
0
10120
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
10061
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
9923
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...
1
7471
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...
1
4031
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
2860
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.