Link to home
Start Free TrialLog in
Avatar of arcross
arcrossFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Save record to database using LINQ to SQL

Hi, I'm trying a simple example of populating a gridview from a view in SQL and updating the records displayed  back to database.

This is how im binding the data to the grid...
Data.BindCustomersDataContext db = new BindCustomersDataContext();
           var items = (from x in db.vwCustomers select x);
            this.gvCustomers.DataSource = items;
            this.gvCustomers.DataBind();

Open in new window


 select x);
                // Field to update here
                db.SubmitChanges();

            }
        }

Open in new window


Im having problems with the code above. What I want to do is to update all the records displayed, to the database, with the value from another column from the view.
row. column1 = row.column2
 
Im not sure how to do this. Do I need to query the view every time to get the ID? and how do I get the field to update from the grid??

Thanks!
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Please post a screenshot of the designer showing the tables in question and if the tables are views or not and the columns to be updated from and to.
Avatar of arcross

ASKER

Hi, at the moment the view is simplest you can get. Just straight from a table. Later on will get a bit more complex. For now, I just wanted to know how to update a series of records in a grid, back to the database.

I want to do 'CustomerStatus = Customer Ack'

CustomerID
CustomerName
CustomerStatus
CustomerAck
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arcross

ASKER

Thanks!!
Not a problem arcross; glad to help.