473,695 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView and Updating

Hi guys,

I am new to GridViews.. I have a gridview that displays 3 columns.
Description, MahUsed and a calculated % Used field.

When I click Edit on the row, the MahUsed goes into Edit mode, and I
can change the value.

Now the problems start.

I click 'Update', and I end up with the original value.

The ObjectDataSourc e has an Update method, that points to this
function:

public void UpdatePackUsage (int Id, int Mahusage)
{
dbfb.UpdatePack Usage(Id, Mahusage);
}

If I put a breakpoint on this function, it is getting hit, however,
the value for Mahusage is always the ORIGINAL value. That is, it never
changes to what I have typed in the edit box.

Do I need to use the RowUpdating event? I'm not at the moment, but am
wondering if I need to do something like:

protected void GridView1_RowUp dating(object sender,
GridViewUpdateE ventArgs e)
{
FlightBatterySe rvice fbs = new FlightBatterySe rvice();
fbs.UpdatePackU sage(int.Parse( e.Keys["Id"].ToString()),
int.Parse(e.New Values["Mahusage"].ToString()));
DataBind();
}

I tried that, and removed the UpdateMethod from the ODS, but then I
get an error about requiring an update method if editing is to be
used.

Hope someone can assit.
Sep 6 '08 #1
3 1073
What's in your Page_Load event? Are you remembering not to only fill the
grid there when it's NOT a postback?

Ken

"Cralis" <in**@listerhom e.comwrote in message
news:bd******** *************** ***********@a3g 2000prm.googleg roups.com...
Hi guys,

I am new to GridViews.. I have a gridview that displays 3 columns.
Description, MahUsed and a calculated % Used field.

When I click Edit on the row, the MahUsed goes into Edit mode, and I
can change the value.

Now the problems start.

I click 'Update', and I end up with the original value.

The ObjectDataSourc e has an Update method, that points to this
function:

public void UpdatePackUsage (int Id, int Mahusage)
{
dbfb.UpdatePack Usage(Id, Mahusage);
}

If I put a breakpoint on this function, it is getting hit, however,
the value for Mahusage is always the ORIGINAL value. That is, it never
changes to what I have typed in the edit box.

Do I need to use the RowUpdating event? I'm not at the moment, but am
wondering if I need to do something like:

protected void GridView1_RowUp dating(object sender,
GridViewUpdateE ventArgs e)
{
FlightBatterySe rvice fbs = new FlightBatterySe rvice();
fbs.UpdatePackU sage(int.Parse( e.Keys["Id"].ToString()),
int.Parse(e.New Values["Mahusage"].ToString()));
DataBind();
}

I tried that, and removed the UpdateMethod from the ODS, but then I
get an error about requiring an update method if editing is to be
used.

Hope someone can assit.

Sep 7 '08 #2
I'm doing this on PageLoad:

protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
FlightLogServic e fls = new FlightLogServic e();
oFlightLog flight =
fls.Get(int.Par se(Session["selectedflight id"].ToString()));

lblAircraft.Tex t = flight.Aircraft ;
lblConfiguratio n.Text = flight.Configur ation;
lblCurveType.Te xt = flight.Curve;
lblDate.Text = flight.Flightda te.ToString("dd MMMM
yyyy");
lblStyle.Text = flight.Flyingst yle;
tbMin.Text = flight.Minutes;
tbSeconds.Text = flight.Seconds;
}
}

So, nothing about the grid...
You're maybe onto something though... But I don't do anything to
populate the grid. I just setup the ODS....
Is there a way to stop it from what it's doing?
Sep 7 '08 #3
No ideas? :(
I think I need to use the Row_Updating event.. but it seems strange...
Sep 9 '08 #4

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

Similar topics

1
2015
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 in advance,
3
6333
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
5034
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...
5
15321
by: Brian McClellan | last post by:
Just wondering if anyone has a simple example of creating a gridview completely programmatically, i'm not doing anything terribly sophisticated. When creating the gridview declaratively evertying works fine, however programmatically, while the grid will display data that exsists in the database, any operation on the data ( editing/updating/deleting ) seems to cause a rowdeleting/updating etc error. Or is this simply not meant to be done?
0
1371
by: Michael Kellogg | last post by:
I have a problem wherein a query that updates a GridView doesn't seem to really stay in sync with a label I have above the GridView. I have a GridView object that I'm updating with information whenever my user enters a job number into a textbox and hits a button. There is a SQLDataSource object on the page that does the retrieval of the data, and the job number parameter for its query is bound to the textbox "Text" value. In the button...
1
4695
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
Hi, I have a gridview which I added a <asp:CommandField EditText="E" CancelText="C" UpdateText="U" ButtonType="Link" ShowEditButton="True" /> my gridview looks like this <asp:GridView ID="GridView1" runat="server" OnRowEditing="RowEdit" OnRowCancelingEdit="RowCancel" OnRowUpdating="RowUpdating"...
11
6062
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
4273
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
1273
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">
2
1789
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 record at all! I placed this code outside of the admin folder and it worked fine. What could be causing...
0
8625
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
8565
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
8977
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
8841
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,...
1
6488
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
4339
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
2997
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
2269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1971
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.