473,473 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Create 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_RowUpdating(object sender,
GridViewUpdateEventArgs 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.DataItemIndex].Value;

//get all other fields to be updated
DropDownList ddl1 = new DropDownList();
ddl1 =
(DropDownList)GridView1.Rows[index].FindControl("ddlCompanyName");
long lngCompanyKey = Convert.ToInt64(ddl1.SelectedValue);

DropDownList ddl2 = new DropDownList();
ddl2 =
(DropDownList)GridView1.Rows[index].FindControl("ddlForecastType");
char chrForecastType = Convert.ToChar(ddl2.SelectedValue);

TextBox txt1 = new TextBox();
txt1 =
(TextBox)GridView1.Rows[index].FindControl("txtMoneyValue");
double dblMoneyValue = Convert.ToDouble(txt1.Text);

DropDownList ddl3 = new DropDownList();
ddl3 =
(DropDownList)GridView1.Rows[index].FindControl("ddlForecastPercentage")
;
double dblForecastPercentage =
Convert.ToDouble(ddl3.SelectedValue);

TextBox txt2 = new TextBox();
txt2 = (TextBox)GridView1.Rows[index].FindControl("txtDueDate");
DateTime dtmDueDate = Convert.ToDateTime(txt2.Text);

//create update parameters
SqlDataSource1.UpdateParameters.Clear();

SqlDataSource1.UpdateParameters.Add("ForecastKey",
TypeCode.Int32, intID.ToString());
SqlDataSource1.UpdateParameters.Add("UserKey", TypeCode.Int32,
UserKey.ToString());
SqlDataSource1.UpdateParameters.Add("CompanyKey",
TypeCode.Int64, lngCompanyKey.ToString());
SqlDataSource1.UpdateParameters.Add("ForecastType" ,
TypeCode.Char, chrForecastType.ToString());
SqlDataSource1.UpdateParameters.Add("MoneyValue",
TypeCode.Double, dblMoneyValue.ToString());
SqlDataSource1.UpdateParameters.Add("ForecastPerce ntage",
TypeCode.Double, dblForecastPercentage.ToString());
SqlDataSource1.UpdateParameters.Add("DueDate",
TypeCode.DateTime, dtmDueDate.ToString());
//update forecast table
DataAccess da = new DataAccess();

da.UpdateForecast(intID, UserKey,
lngCompanyKey, chrForecastType,
dblMoneyValue, dblForecastPercentage,
dtmDueDate);

GridView1.EditIndex = -1;

//refresh gridview
GridView1.DataBind();
}

*** Sent via Developersdex http://www.developersdex.com ***
Jun 7 '06 #1
1 1388
K B
For example, I want to get the value of the vlaue in the UserName field
in EditItemTemplate. On the RowUpdating event, I use this:

Dim sUserName As String = e.NewValues("UserName")

HTH,
KB

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

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

Similar topics

3
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...
2
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...
3
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...
0
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...
0
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...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
2
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...
1
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...
1
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...
1
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
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...
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...
1
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...
0
agi2029
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.