adskarcox
asked on
Add row to DataSet Programmatically
Hello,
Let's say we generate this link-to-sql dataset for a grid:
We need to programmatically add "Vince Vaughn" to this dataset in a manner that will allow him to be the top row in the grid.
How would be accomplish this programmatically using C#? (i.e. programmatically add a row for Vince Vaughn to the dataset, and do so in a manner that this new row is "on the top", so that it will be the first row in the grid)
CUSTOMERS
ID FirstName LastName
1 John Jones
2 Sally Smith
Environment: C#.NET 4.0
Let's say we generate this link-to-sql dataset for a grid:
var query = from c in customers
orderby c.FirstName
select c;
Grid1.DataSet = query;
Grid1.DataBind();
We need to programmatically add "Vince Vaughn" to this dataset in a manner that will allow him to be the top row in the grid.
How would be accomplish this programmatically using C#? (i.e. programmatically add a row for Vince Vaughn to the dataset, and do so in a manner that this new row is "on the top", so that it will be the first row in the grid)
CUSTOMERS
ID FirstName LastName
1 John Jones
2 Sally Smith
Environment: C#.NET 4.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for posting. The example you provided is interesting, but it only shows how to create a dataset from scratch, without any linq-to-sql input.
I need the linq-to-sql side of things to be able to fully understand how to do this.
Thanks again.
I need the linq-to-sql side of things to be able to fully understand how to do this.
Thanks again.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
roopeshreddy- thanks for posting that link that goes of linq-to-sql.
So far, amarpal0102 posted some links that cover how to create a dataset and add rows to it and roopeshreddy has posted a link that goes over linq-to-sql. What I really need, however, is a code sample that merges the two.
Here is my question: How do I add a row to the query dataset listed in this code:
So far, amarpal0102 posted some links that cover how to create a dataset and add rows to it and roopeshreddy has posted a link that goes over linq-to-sql. What I really need, however, is a code sample that merges the two.
Here is my question: How do I add a row to the query dataset listed in this code:
var query = from c in customers
orderby c.FirstName
select c;
Grid1.DataSet = query;
Grid1.DataBind();
I need someone to post some code, not links. Thank you.
http://stackoverflow.com/questions/3125864/adding-rows-to-dataset