473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2305
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.C ount;

int intIndex = 0;

while (intIndex < intCount)
{

TextBox strDateOfClean =
GridMain.Rows[intIndex].FindControl("s trDateOfClean") 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.C ount;

int intIndex = 0;

while (intIndex < intCount)
{

TextBox strDateOfClean =
GridMain.Rows[intIndex].FindControl("s trDateOfClean") 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
928
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 second, and everytime I set a property of each control the form is redrawn. I would like to suppress redrawing until I am done updating all the...
6
11209
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 programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch...
1
3166
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 programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS...
0
2136
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 have one save button to submit all the hours that user entered. On the backend save button clicked event, I mannually build my update statement to...
3
1555
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 column which duly fire the relevent events, I have handled the edit and canel events OK, but Im having problem with the row_updated event. I...
6
2628
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 rows of the GridView and then hit an "OK" button which then applies all the changes together as a single unit. I also need the GridView to support...
2
2987
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 = @Shipped The Shipped column is a bit type column that is returned in the
5
2163
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 always 0 and not the ID of the selected record (which is the case when updating) How come?
4
12015
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 update panel that the gridview is in. In my page render I put this so I could select a row by just clicking it. protected override void...
0
7836
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...
0
8199
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. ...
0
8336
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...
0
6606
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
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...
0
5389
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...
1
2343
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
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
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...

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.