Hi,
I went through your article regarding MVC its very useful for me.
Can i get some example on grid where we can use paging, sorting etc in the same project only. (MymobilewalaMvc)
Thanks & Regards
Himanshu Verma
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lakshmanan Sethu SankaranarayanPosted Jun 4, 2014, 2:33 AM
Please check this link
http://demos.devexpress.com/MVCxGridViewDemos/GroupingSorting/Sorting
Jignesh TrivediPosted Jun 4, 2014, 2:31 AM
Hi,
we have two option for grid in MVC
1)MVCContrib grid : this is not inbuilt grid
http://www.codeproject.com/Articles/170921/MvcContrib-Grid-Paging-and-Searching-in-ASP-NET-MV
http://www.4guysfromrolla.com/articles/031611-1.aspx
2)webgrid : this is available with MVC4
http://www.codeproject.com/Tips/615776/WebGrid-in-ASP-NET-MVC
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
http://www.dotnet-tricks.com/Tutorial/mvc/GK2W110113-WebGrid-with-custom-paging-and-sorting-in-MVC4.html
hope this will help you.
Rajagopalan R VPosted Jun 4, 2014, 2:20 AM
Himanshu Verma
<asp:GridView ID="gvrecords" runat="server" AllowPaging="true" AllowSorting="true"
AutoGenerateColumns="false" ShowFooter="true" Style="margin-top: 50px; margin-left: 7px"
Width="1049px" OnRowCommand=" gvrecords_OnRowCommand" OnRowCancelingEdit=" gvrecords_RowCancelingEdit"
OnRowDeleting=" gvrecords_RowDeleting" OnRowEditing=" gvrecords_RowEditing" OnRowUpdating=" gvrecords_RowUpdating"
OnPageIndexChanging="gvrecords_PageIndexChanging" OnSorting="gvrecords_Sorting" PageSize="4">
PAGING:
Tag's Needed to Paging
AllowPaging="true" ------> This Will Enable PagingPageSize="4" -------> This is to Declare How Many Records to Display in Single Page
OnPageIndexChanging="gvrecords_PageIndexChanging"
Code for Paging in .cs file
protected void gvProjects_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvrecords.PageIndex = e.NewPageIndex;
BindGrid();
}
SORTING :
Tag's Needed to Sorting
AllowSorting="true"
OnSorting="gvrecords_Sorting"
Code for Sorting in .cs file
protected void gvrecords_Sorting(object sender, GridViewSortEventArgs e)
{
BindGrid();
DataTable dt = new DataTable();
..
..
{
string SortDir = string.Empty;
if (dir == SortDirection.Ascending)
{
dir = SortDirection.Descending;
SortDir = "Desc";
}
else
{
dir = SortDirection.Ascending;
SortDir = "Asc";
}
DataView sortedView = new DataView(dt);
sortedView.Sort = e.SortExpression + " " + SortDir;
gvrecords.DataSource = sortedView;
gvrecords.DataBind();
}
}
If You Clear With The Solution For What You Queried For, Kindly Mark it Has Answer
With Regards.......,
R.V.Rajagopalan
Khan Abrar AhmedPosted Jun 4, 2014, 2:17 AM
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application