473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView Updating

I want to update my gridview, but rather than specifying the Update
Parameters etc in the GridView, I want to use my own code similar to the
way I updated the DataGrid v1.1. I also want to make a call to a
seperate data class to do this.

Here is my code :

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{

if (e.CommandName == "Update")
{
// 1)Convert the row index stored in the CommandArgument
property to an Integer
int index = Convert.ToInt32(e.CommandArgument);

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

//get datakeys
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("ddlTeamType");
int intTeamKey = Convert.ToInt32(ddl1.SelectedValue);

DropDownList ddl3 = new DropDownList();
ddl3 =
(DropDownList)GridView1.Rows[index].FindControl("ddlTerritoryCode");
int intTerritoryCode = Convert.ToInt32(ddl3.SelectedValue);

TextBox txt1 = new TextBox();
txt1 =
(TextBox)GridView1.Rows[index].FindControl("txtUserName");
string strUserName = Convert.ToString(txt1.Text);

TextBox txt2 = new TextBox();
txt2 =
(TextBox)GridView1.Rows[index].FindControl("txtUserLogin");
string strUserLogin = Convert.ToString(txt2.Text);

TextBox txt3 = new TextBox();
txt3 =
(TextBox)GridView1.Rows[index].FindControl("txtPassword");
string strPassword = Convert.ToString(txt3.Text);

TextBox txt4 = new TextBox();
txt4 =
(TextBox)GridView1.Rows[index].FindControl("txtEmail");
string strEmail = Convert.ToString(txt4.Text);

DropDownList ddl4 = new DropDownList();
ddl4 =
(DropDownList)GridView1.Rows[index].FindControl("ddlRegion");
string strRegion = Convert.ToString(ddl4.SelectedValue);

DropDownList ddl5 = new DropDownList();
ddl5 =
(DropDownList)GridView1.Rows[index].FindControl("ddlBusinessUnit");
string strBusinessUnit =
Convert.ToString(ddl5.SelectedValue);

//update userlogin table
DataAccess da = new DataAccess();

DBResult dbrUpdateUser =
(Xerox.DBResult)da.UpdateUserList(intID,
intTeamKey,
intTerritoryCode,
strUserName,
strUserLogin,
strPassword,
strEmail,
strRegion,
strBusinessUnit);

GridView1.EditIndex = -1;

//refresh gridview
GridView1.DataBind();
}

What do I need to change in the grdiview for this code to work, or do I
need to change my code?

*** Sent via Developersdex http://www.developersdex.com ***
May 23 '06 #1
0 1220

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

Similar topics

1
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...
3
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...
8
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...
5
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...
0
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...
1
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...
11
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...
0
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...
0
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"...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...
0
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,...

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.