Solved

Binding a datagrid using 3 tier architecture and LINQ

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
crm development 2 37
asp.net bundle 8 36
How do I bind the results to a grid 3 24
Visual Studio: built-in keystroke automation 2 26
Software development teams often use in-memory caches to improve performance. They want to speed up access to, or reduce load on, a backing store (database, file system, etc.) by keeping some or all of the data in memory.   You should implement a …
Introduction This article discusses the Chain of Responsibility pattern, explaining What it is;Why it is; andHow it is At the end of this article, I hope you will be able to describe the use and benefits of Chain of Responsibility.  Backgrou…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

9 Experts available now in Live!

Get 1:1 Help Now