hello all, I am receiving data on Browse.aspx page with the help of model now i want to add pagging to the table i am displaying ...code is...
<%@ Page Title="Max 2.0" Language="C#" MasterPageFile="~/Views/Shared/Master.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<FMDomain.Models.User>>" %>
<%@ Import Namespace="FM.UI.Web" %>
<%@ Import Namespace="FM.UI.Web.Controllers" %>
<%@ Import Namespace="MvcPaging" %>
<asp:Content ID="BrowseTitleContent" ContentPlaceHolderID="TitleContent" runat="server">
Browse
</asp:Content>
<asp:Content ID="BrowseMainContent" ContentPlaceHolderID="mainContentPlaceHolder" runat="server">
<script language="javascript">
function Clear() {
//alert("hello");
document.getElementById('IDUserName').value = "";
document.getElementById('IDEmail').value = "";
document.getElementById('IDFirstName').value = "";
document.getElementById('IDLastName').value = "";
}
}
</script>
<link rel="stylesheet" href="../../Images/StyleSheet.css" type="text/css">
<form ID="aspnetForm" name=Browseform runat="server" action="/User/Browse" method="post" >
<asp:ToolkitScriptManager ID="GInfoToolkitScriptManager" runat="server"> </asp:ToolkitScriptManager>
<table align="center" style="font-family:Arial;font-size:12px; width: 100%;" >
<tr height="20px">
<td >Employee/User Management</td>
</tr>
<tr>
<td width="100%">
<asp:TabContainer ID="UserManagement" runat="server" ActiveTabIndex="0"
TabStripPlacement="Top" Font-Size="Large" BorderStyle="None" Height="400px" >
<% if (Utilities.checkPermissions(1, "UserBrowseTab", "UserManagement") == true)
{%>
<asp:TabPanel runat="server" HeaderText="Browse" ID="tabBrowse" Enabled="true">
<HeaderTemplate>
Browse
</HeaderTemplate>
<ContentTemplate>
<table width="100%" align="center" class="grid" >
<tr>
<td>
<table align="center" width="50%">
<tr>
<td align="right" class="label">
<asp:Label ID="lblUserName" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblUserName %>" ></asp:Label>
</td>
<td align="left">
<input type=text id="IDUserName" name="TxtUserName" value="<%=ViewData["UserName"]%>" size="21px" />
</td>
<td align="right" class="label">
<asp:Label ID="lblEmail" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblEmail %>" ></asp:Label>
</td>
<td align="left">
<input type=text id="IDEmail" name="TxtMail" value="<%=ViewData["UserEmail"]%>" size="21px" />
</td>
</tr>
<tr>
<td align="right" class="label">
<asp:Label ID="lblFirstName" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblFirstName %>" ></asp:Label>
</td>
<td align="left">
<input type=text id="IDFirstName" name="TxtFirstName" value="<%=ViewData["UserFirstName"]%>" size="21px" />
</td>
<td align="right" class="label">
<asp:Label ID="lblLastName" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblLastName %>" ></asp:Label>
</td>
<td align="left">
<input type=text id="IDLastName" name="TxtLastName" value="<%=ViewData["UserLastName"]%>" size="21px" />
</td>
</tr>
<tr>
<td align="right" class="label">
<asp:Label ID="lblStatus" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblStatus %>" ></asp:Label>
</td>
<td align="left">
<select name="DdlStatus" atomicselection="true" style="width:152px;">
<option value="1" value="<%=ViewData["UserStatus"]%>">Active</option>
<option value="0" value="<%=ViewData["UserStatus"]%>">InActive</option>
</select>
</td>
<td align="right" class="label">
<asp:Label ID="lblUserRole" runat="server" CssClass="label" Text="<%$ Resources:UserManagement, lblUserRole %>" ></asp:Label>
</td>
<td align="left">
<select name="DdlRole" atomicselection="true" style="width:152px;">
<option value="<%=ViewData["UserRole"]%>">M</option>
<option value="<%=ViewData["UserRole"]%>">U</option>
</select>
<%-- <input type=text name="TxtRole" value="<%=ViewData["UserRole"]%>" size="21px">--%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=4 align="right">
<input type="submit" class="button" ID="BtnSearch" name="button" value="Search" size="10px" />
<input type="button" class="button" ID="BtnClear" name="button" value="Clear" size="10px" onclick="Clear()"/>
</td>
</tr>
<tr>
<td align="right" colspan=4>
<input type="submit" class="button" ID="btnAddUser" name="button" value="Add User" />
</td>
</tr>
<%if (Model != null)
{
// string list = null;
//foreach ( var head in Model)
//{
// list = head.ToString();
//}
//if (list != null)
//{
%>
<tr>
<td colspan=4 align="center">
<table width="100%" border=2 align="center">
<tr>
<td align="center" class="td_bgcolor" class="label"> User Name </td>
<td align="center" class="td_bgcolor" class="label"> First Name </td>
<td align="center" class="td_bgcolor" class="label"> Last Name </td>
<td align="center" class="td_bgcolor" class="label"> E-mail </td>
<td align="center" class="td_bgcolor" class="label"> Role </td>
<td align="center" class="td_bgcolor" class="label"> Status </td>
<td align="center" class="td_bgcolor"> </td>
</tr>
<% foreach (var user in ViewData.Model)%>
<%{ %>
<tr>
<td align="center"><%=Html.ActionLink(user.UserName, "GeneralInfo", new { id = user.UserID })%></td>
<td align="center"><%=user.FirstName%></td>
<td align="center"><%=user.LastName%></td>
<td align="center"><%=user.Email%></td>
<td align="center">
<% string UserRole = "";
if (user.Roles.Count() > 0)
{
foreach (var role in user.Roles)
{
if (UserRole == "")
{
UserRole = role.RoleName;
}
else
{
UserRole = UserRole + "," + role.RoleName;
}
}
}
Response.Write(UserRole);
%>
</td>
<td align="center"><%=(FMDomain.Models.FMEnums.Status)user.Status%></td>
<td align="center">
<%--<%= Html.ActionLink("Delete", "DeleteUser", new { id = user.UserID })%>--%>
<%--<a href="<%= { id = user.UserID })%>" id="postDel" onclick="PostForm('postDel')">Delete</a>--%>
<%--<a href="User/DeleteUser" id="postDel" onclick="PostForm('id')" >Delete</a>--%>
<a href="<%= Url.Action("DeleteUser","User", new {id=user.UserID})%>" onclick="PostForm('id')" >Delete</a>
<%--<a href="<%Url.Action("DeleteUser", "User", new { id = user.UserID })%>" id="postDel" onclick="PostForm('id')">Delete</a>--%>
</td>
</tr>
<% } %>
</table>
<%-- <div class="pager">
<%= Html.Pager(ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalItemCount, new { categoryname = ViewData["CategoryDisplayName"] })%>
</div>--%>
</td>
</tr>
<%--<tr>
<td colspan=4 align=center>
<table align="center" width="100%">
<tr>
<td align="center">
<asp:HyperLink ID="hyplnkFirst" runat=server Text="<<" Width="20px" BorderWidth="1px" ></asp:HyperLink>
<asp:HyperLink ID="HyperLink1" runat=server Text="<" Width="20px" BorderWidth="1px" ></asp:HyperLink>
<asp:HyperLink ID="HyperLink2" runat=server Text="1" Width="20px" BorderWidth="1px" Font-Underline=True></asp:HyperLink>
<asp:HyperLink ID="HyperLink3" runat=server Text="2" Width="20px" BorderWidth="1px" Font-Underline=True></asp:HyperLink>
<asp:HyperLink ID="HyperLink4" runat=server Text=">" Width="20px" BorderWidth="1px" ></asp:HyperLink>
<asp:HyperLink ID="HyperLink5" runat=server Text=">>" Width="20px" BorderWidth="1px" ></asp:HyperLink>
</td>
</tr>
</table>
</td>
</tr>--%>
</table>
<%=ViewData["Result"]%> Results Fetched
<%
} %>
</ContentTemplate>
</asp:TabPanel>
<%} if(Utilities.checkPermissions(1, "UserGeneralTab", "UserManagement") == true){%>
<asp:TabPanel ID="tabAdd" runat="server" HeaderText="General Info" >
</asp:TabPanel>
<%} %>
</asp:TabContainer>
</td>
</tr>
</table>
</form>
</asp:Content>