473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting at edited values in gridview

How do you get access to the values you have entered under edit mode in
a gridview? I only seem to be able to access the values prior to them
being edited.

protected void GridView1_RowUp dating(object sender,
GridViewUpdateE ventArgs e)
{
// 1)Convert the row index stored in the CommandArgument
property to an Integer
int index = e.RowIndex;

// Retrieve the row that contains the button clicked by the user
from the Rows collection
GridViewRow row = GridView1.Rows[index];

//get datakeys (forecastkey)
int intID = (int)GridView1. DataKeys[row.DataItemInd ex].Value;

//get all other fields to be updated
DropDownList ddl1 = new DropDownList();
ddl1 =
(DropDownList)G ridView1.Rows[index].FindControl("d dlCompanyName") ;
long lngCompanyKey = Convert.ToInt64 (ddl1.SelectedV alue);

DropDownList ddl2 = new DropDownList();
ddl2 =
(DropDownList)G ridView1.Rows[index].FindControl("d dlForecastType" );
char chrForecastType = Convert.ToChar( ddl2.SelectedVa lue);

TextBox txt1 = new TextBox();
txt1 =
(TextBox)GridVi ew1.Rows[index].FindControl("t xtMoneyValue");
double dblMoneyValue = Convert.ToDoubl e(txt1.Text);

DropDownList ddl3 = new DropDownList();
ddl3 =
(DropDownList)G ridView1.Rows[index].FindControl("d dlForecastPerce ntage")
;
double dblForecastPerc entage =
Convert.ToDoubl e(ddl3.Selected Value);

TextBox txt2 = new TextBox();
txt2 = (TextBox)GridVi ew1.Rows[index].FindControl("t xtDueDate");
DateTime dtmDueDate = Convert.ToDateT ime(txt2.Text);

//create update parameters
SqlDataSource1. UpdateParameter s.Clear();

SqlDataSource1. UpdateParameter s.Add("Forecast Key",
TypeCode.Int32, intID.ToString( ));
SqlDataSource1. UpdateParameter s.Add("UserKey" , TypeCode.Int32,
UserKey.ToStrin g());
SqlDataSource1. UpdateParameter s.Add("CompanyK ey",
TypeCode.Int64, lngCompanyKey.T oString());
SqlDataSource1. UpdateParameter s.Add("Forecast Type",
TypeCode.Char, chrForecastType .ToString());
SqlDataSource1. UpdateParameter s.Add("MoneyVal ue",
TypeCode.Double , dblMoneyValue.T oString());
SqlDataSource1. UpdateParameter s.Add("Forecast Percentage",
TypeCode.Double , dblForecastPerc entage.ToString ());
SqlDataSource1. UpdateParameter s.Add("DueDate" ,
TypeCode.DateTi me, dtmDueDate.ToSt ring());
//update forecast table
DataAccess da = new DataAccess();

da.UpdateForeca st(intID, UserKey,
lngCompanyKey, chrForecastType ,
dblMoneyValue, dblForecastPerc entage,
dtmDueDate);

GridView1.EditI ndex = -1;

//refresh gridview
GridView1.DataB ind();
}

*** Sent via Developersdex http://www.developersdex.com ***
Jun 7 '06 #1
0 1830

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

Similar topics

3
5677
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the GridView to allow entry of quantity and Y/N switch for
2
1695
by: Kiran Kumar Pinjala | last post by:
Hi, May be this is silly, or I just need a second pair eyes to look at this. I am trying to get values that I have edited in a datagrid and update the values with those values. Here is the code that I am using in my update command. TextBox txtProdName = (TextBox)e.Item.Cells.Controls; TextBox txtSuppID = (TextBox)e.Item.Cells.Controls; TextBox txtCatID = (TextBox)e.Item.Cells.Controls;
3
3879
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a GridView control, each with its own SqlDataSource. FormView1 talks to my Opportunity table and has an ItemTemplate and an EditItemTemplate. FormView2 talks to my Activities table and has an ItemTemplate, InsertItemTemplate and an...
1
1403
by: Mike P | last post by:
How do you get access to the values you have entered under edit mode in a gridview? I only seem to be able to access the values prior to them being edited. protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { // 1)Convert the row index stored in the CommandArgument property to an Integer int index = e.RowIndex;
0
2387
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an ItemTemplate in the GridView populated with three ListItems. A Button to Submit the form.
2
1142
by: J | last post by:
Using codebehind, I populate some textboxes in the Page_Load method. At this point the user can edit the data in the textboxes. Then I want to click on a Save button and write the edited data in the textboxes into a table. But referencing the textboxes only shows the original value, not the newly edited values. protected void btnSave_Click(object sender, EventArgs e) { // This contains original values not edited values...
1
2365
by: dan | last post by:
Hi, I'd like to the row being edited to be also selected. That is, I don't want one row to be selected while another row is being edited. If a user clicks on the 'Edit' button I'd like the Select to be executed first, followed by Edit. So, if there is a details view associated with the GridView I'd like the details to show the content of the row being edited. Could someone please let me know what the proper procedure should be?
1
1705
by: nomad | last post by:
Hi, I have an editable GridView. When I select Edit it jumps into the RowEditing event. Within this even I can get the row index of the row being edited, along with the value of the column to be edited before it has been edited. My question is, how can I retrieve these values within the SQLDataSource_Updating event? Thanks for any suggestions
1
1230
by: Mark B | last post by:
VB.NET: How do I get the value of a particular field in the currently edited gridview row?
0
9641
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
10313
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
10146
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...
0
9944
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
7494
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
6735
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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 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.