• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 612
  • Last Modified:

Add row to DataSet Programmatically

Hello,

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();

Open in new window


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
0
adskarcox
Asked:
adskarcox
  • 2
  • 2
2 Solutions
 
amarpal0102Commented:
0
 
amarpal0102Commented:
0
 
adskarcoxAuthor Commented:
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.
0
 
Roopesh ReddyCommented:
Hi,

Check the Code project article on Linq-Sql!

http://www.codeproject.com/Articles/26657/Simple-LINQ-to-SQL-in-C

Hope it helps u...
0
 
adskarcoxAuthor Commented:
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:

var query = from c in customers
                    orderby c.FirstName
                    select c;

Grid1.DataSet = query;
Grid1.DataBind();

Open in new window

I need someone to post some code, not links.  Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now