Solved

Binding a datagrid using 3 tier architecture and LINQ

Posted on 2013-05-16
4
1,457 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now