Solved

Binding a datagrid using 3 tier architecture and LINQ

Posted on 2013-05-16
4
1,471 Views
Last Modified: 2013-05-22
I am just getting started with web applications and 3-tier-archtecture.    I worked through the article below and felt pretty confident.  However I cannot figure how to expand this knowledge to allow me to retrieve a block of data and bind to a datagridview.  

I get the stored procedures for Insert, Update and Delete, but how do I return a record set to bind my datagridview to?

Can anyone provide an example that would allow me further apply this?
http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-3-tier-application-using-linq/
0
Comment
Question by:ITGuy4life
  • 2
4 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 39174009
The same link, has a sample project...did you try that ?
0
 
LVL 12

Expert Comment

by:jitendra patil
ID: 39174476
try the link given below

Data Binding using LINQ to SQL in C#

hope this helps.
0
 

Accepted Solution

by:
ITGuy4life earned 0 total points
ID: 39175416
Thanks Guys;

I got where I needed to be.  

The first article:  http://www.c-sharpcorner.com/uploadfile/jayendra/how-to-create-3-tier-application-using-linq/  provides a good overview on 3-tier applications using linq but doesn't address databinding.

The second article:  http://www.c-sharpcorner.com/UploadFile/lakshmanmcaj/using-linq-to-sql-query/  provides a good tutorial for databinding but does not follow the three tier architecture.

With both of those and a little help from a friend I was able to create the following function in my business layer:

public IEnumerable<myDataTable> GetDocs()
{
    using (MyDataContext db = new MyDataContext()
        {
            var result = db.MyDataTable();
            return result.ToList();
        }
}

And call it from my Page_Load event like this:

    var dt = new BusinessLogicLayer.MyBusinessLogicClass
    GridView1.DataSource = dt.GetDocs();
    GridView1.DataBind();
0
 

Author Closing Comment

by:ITGuy4life
ID: 39186874
I arrived at a solution through multiple sources.  My response contains all of the pieces necessary to solve this problem.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Fluent Interface Design Pattern You can use the Fluent Interface (http://en.wikipedia.org/wiki/Fluent_interface) design pattern to make your PHP code easier to read and maintain.  "Fluent Interface" is an object-oriented design pattern that r…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question