473,394 Members | 1,845 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,394 software developers and data experts.

Batch Update in GridView control, is it possible?


Is it possible to update all the rows in a single postback using
Gridview Control,

regards
John

Jun 23 '06 #1
2 2296
John

I am assuming you already have template columns set up to enter the
data into.

For this example I am using a TextBox inside a template column called
strDateOfClean.
int intCount = GridMain.Rows.Count;

int intIndex = 0;

while (intIndex < intCount)
{

TextBox strDateOfClean =
GridMain.Rows[intIndex].FindControl("strDateOfClean") as TextBox;
//Then you can do what you need to here to save the
//strDateOfClean, such as updating an SQL table. e.g. Adding it to an
SQL string
//and firing a command.
//string strsql = "Update tblTest set strTest = '" +
strDateOfClean.Text + "'";

intIndex += 1;

}
Cheers

Jared
Le************@gmail.com wrote:
Is it possible to update all the rows in a single postback using
Gridview Control,

regards
John


Jun 23 '06 #2
Missed a couple of bits you might need...

This code can be fired from a button or a row command, either will
work.

In the SQL string I missed out that you need to refernce a primary key,
which needs to be stored in your GridView somewhere, e.g.

string strsql = "Update tblTest set strTest = '" + strDateOfClean.Text
+ "' where ID = " + GridMain.Rows[intIndex].Cells[0].Text;

Hope this is useful

Jared

Jared wrote:
John

I am assuming you already have template columns set up to enter the
data into.

For this example I am using a TextBox inside a template column called
strDateOfClean.


int intCount = GridMain.Rows.Count;

int intIndex = 0;

while (intIndex < intCount)
{

TextBox strDateOfClean =
GridMain.Rows[intIndex].FindControl("strDateOfClean") as TextBox;
//Then you can do what you need to here to save the
//strDateOfClean, such as updating an SQL table. e.g. Adding it to an
SQL string
//and firing a command.
//string strsql = "Update tblTest set strTest = '" +
strDateOfClean.Text + "'";

intIndex += 1;

}
Cheers

Jared
Le************@gmail.com wrote:
Is it possible to update all the rows in a single postback using
Gridview Control,

regards
John


Jun 23 '06 #3

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

Similar topics

0
by: shumaker | last post by:
How do I prevent repainting while updating a batch of controls? Datagrids have functions to do this, but many other controls do not. I have a large number of controls that I update a few times a...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
0
by: rockdale | last post by:
Hi, I have a web page which let user data enter employee working hours. I used datagrid to list all the employee and templateColumn to format the workhours column to textbox for data entry. And...
3
by: Just Me | last post by:
Im struggling a bit with the update function. I have bound a table with lets say 5 records ( 4 columns ) to the gridview , this displays jsut fine. I have added edit/cancel/update buttons in a...
6
by: McGeeky | last post by:
Hi. GridView's inbuilt capability to edit/update individual rows, one at a time, is useful but inadequate for a scenario we currently face. I want the user to be able to change values in multiple...
2
by: Looch | last post by:
Hi, I'm filling a GridView with a simple sproc select statement. I'm trying to use the Update tab to create an update statement and using the following: Update Shipping_Requests Set Shipped...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
4
by: BiffMaGriff | last post by:
Hello, I have a GridView that I put inside an update panel. I have a control that attaches to the datasource of the gridview that filters the data, databinds the gridview and then updates the...
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: 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
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...
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
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...

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.