What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 57203 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > how to bind grid in mvc3 in asp.net ...
Meenakshi

how to bind grid in mvc3 in asp.net

Replies: 3 | Posted by: Meenakshi on 5/5/2012 | Category: ASP.NET Forums | Views: 4114 | Status: [Member] | Points: 10  


hi,
i m new in mvc so i want to know how to bind gridview in mvc.
Thanks


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Kavi.Sirius
Kavi.Sirius  
Posted on: 5/7/2012 12:28:35 AM
Level: Starter | Status: [Member] | Points: 25

HI,
In mvc u have a three layer

create the class in three layer:

presentation Layer:
In this layer call the Business Layer method
Business Layer:
In this layer call the dataaceess layer method
Dataaccess Layer:
It exectues the query.

All this methods are returns a value through Dataset

Example:

Presentation layer:

public partial class website1 : System.Web.UI.Page
{
Businesslayerclass objbusiness=new Businesslayerclass();

public void page_load()
{
}
public void Gridviewbinddata()
{
Dataset ds=new Dataset();
ds=objbusiness.GridviewBind();//call the businesslayer method
Gridview1.Datasource=ds;
Gridview1.DataBind();
}
}

BusinessLayer://class file


public class Businesslayerclass
{
Dataacesslayerclass objData=new Dataacesslayerclass();
public Dataset GridviewBind()
{
Dataset ds=new Dataset();
ds=objData.GridViewData();//call the dataaccesslayer method
return ds;
}
}

DataaacessLayer://class file

public class DataaacessLayer
{
sqlconnection con=new sqlconnection("database path");
sqlcommand cmd=new sqlcommand();
sqlDataAdapter da=new SqlDataAdapter();

public Dataset GridviewData()
{
Dataset ds=new Dataset();
con.open();
string StrQuery="select * from employeedetail";//query
ds=cmd.ExecuteNonQuery(StrQuery);
da.fill(ds);
return ds;//returns the dataset value to the business layer
}

i hope it helps you.........







Regards
Kavi.n

Meenakshi, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Dhiren.Kaunar@Gmail.Com
Dhiren.Kaunar@Gmail.Com  
Posted on: 5/7/2012 11:00:36 AM
Level: Starter | Status: [Member] | Points: 25

Hi Meenakshi,

This can be archive archive in many ways :
There are some below different possibilities:
Server side grids:
The built-in WebGrid helper : http://weblogs.asp.net/andrebaltieri/archive/2010/11/01/asp-net-mvc-3-working-with-webgrid.aspx
MvcContrib Grid : http://mvccontrib.codeplex.com/wikipage?title=Grid
Telerik Grid : http://www.telerik.com/products/aspnet-mvc/grid.aspx

Client-Side grids:
jqGrid : http://www.trirand.com/blog/
YUI DataTable : http://developer.yahoo.com/yui/datatable/



http://weblogs.asp.net/andrebaltieri/archive/2010/11/01/asp-net-mvc-3-working-with-webgrid.aspx

Thanks & Rgards,
Dhiren Kumar Kaunar

Meenakshi, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vinay13mar
Vinay13mar  
Posted on: 11/4/2012 11:46:28 AM
Level: Starter | Status: [Member] | Points: 25

Meenakshi, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 10:09:50 AM