Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Saving gridview data changes, ASP.NET VB grrrr...

views
     
unrealweapon
post Jan 30 2009, 10:32 AM

it's painful.
*****
Senior Member
865 posts

Joined: Jan 2008
From: Paradise City


QUOTE(gsrc @ Jan 30 2009, 10:28 AM)
I wanted to save the whole changes done to the dropdownlist and the date, so when user clicked the SAVE button, the whole table will be saved, but I am having problem doing it. Can anyone help?
user posted image

I've tried the following but in vain. No update were done.
CODE
Dim i As Integer
While (i < GridView1.Rows.Count)
       GridView1.UpdateRow(i, False)
       i += 1
End While

Am I looking at the right place? Should I be saving the dataset instead of saving the gridview instead? Any help would be appreciated thanks.
*
hi

check your code under the aspx file, u need update command (SQL) for ur UpdateRow to work.
if u do not have, i suggest u save the dataset.Datatable instead.
unrealweapon
post Jan 30 2009, 10:44 AM

it's painful.
*****
Senior Member
865 posts

Joined: Jan 2008
From: Paradise City


QUOTE(gsrc @ Jan 30 2009, 10:37 AM)
I'm not using .aspx to bind the dataset so I'll have to skip that for the now.

As for the save dataset.dataTable part, do you mean using the code below?
CODE
           ds.Tables("ROSTERWEEKEND").AcceptChanges()

*
depending on how u do it,

for database <-> dataset, the must be a link, such as datatable adapter or binding


if u are declaring a dataset via code, most likely u need to loop ur dataset.
eg: dataset = " dataset something from sql"

AcceptChanges() wont help.

i strongly suggest using binding method. as this will help u alot coz binding method will reduce codes and sql.

if u view is combination of alot of 2 or more tables, u can still use binding method, write u update statement in an procedure, use ur store procedure in ur dataset, a simple loop to update ur data.

This post has been edited by unrealweapon: Jan 30 2009, 10:47 AM
unrealweapon
post Jan 30 2009, 10:49 AM

it's painful.
*****
Senior Member
865 posts

Joined: Jan 2008
From: Paradise City


QUOTE(gsrc @ Jan 30 2009, 10:46 AM)
I wanted to save the whole gridview instead of row by row anyway. icon_rolleyes.gif

*
saving row by row is waste of time and resources.

when use dataset.datatable binding, each modified row has a state. such as modified, deleted, new .. bla bla bla..

therefore, u can prevent same unmodified row from reupdate which save alot of resource when u have alot of records.

unrealweapon
post Jan 30 2009, 11:21 AM

it's painful.
*****
Senior Member
865 posts

Joined: Jan 2008
From: Paradise City


QUOTE(geekster129 @ Jan 30 2009, 11:11 AM)
Did some study on Gridview and found out that there's some SQL commands that you'll put together with the Gridview control declaration. I suspect that upon running the UpdateRow method, the SQL UPDATE associated to it might be incorrect. Check if that is correct.
*
yes.. u have to declare the update method.. u can even put store procedure as sql to do updates.

 

Change to:
| Lo-Fi Version
0.0151sec    0.81    6 queries    GZIP Disabled
Time is now: 23rd December 2025 - 02:47 AM