Click here to Skip to main content
15,891,136 members
Articles / Web Development / ASP.NET

Advanced ASPX GridView Pagination and Data Entities

Rate me:
Please Sign up or sign in to vote.
4.90/5 (46 votes)
14 Feb 2013CPOL11 min read 221K   12.2K   107  
ASP.NET based software system skeleton that uses the ASPX GridView control and advanced pagination for displaying a list of data entities loaded from the database, and the ASP.NET AJAX ModalPopupExtender control for creating new entities or for editing entities from the grid.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContactPage.aspx.cs" Inherits="Ra.GridView.Web.ContactPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">

        function OnOK() {
            window.parent.document.getElementById('_okPopupButton').click();
        }

        function OnCancel() {
            window.parent.document.getElementById('_cancelPopupButton').click();
        }
    </script>
</head>
<body>
    <form id="_mainForm" runat="server">
    <asp:ScriptManager ID="_pageScriptManager" runat="server">
    </asp:ScriptManager>
    <div class="popupContainer">
        <div class="popupTitlebar" id="PopupHeader">
            <div class="titlebarLeft">
                <asp:Literal ID="_titleLiteral" runat="server" Text="Contact" />
            </div>
            <div class="titlebarRight" onclick="OnCancel();">
            </div>
        </div>
        <div class="popupBody">
            <table cellspacing="10px" cellpadding="0px">
               <%-- <tr>
                    <td colspan="6">
                        <asp:ValidationSummary ID="_contactValidationSummary" runat="server" CssClass="failureNotification"
                            ValidationGroup="ContactValidationGroup" />
                    </td>
                </tr>--%>
                <tr>
                    <td>
                        <asp:Literal ID="_firstNameLiteral" runat="server" Text="First Name" />
                    </td>
                    <td>
                        <asp:TextBox ID="_firstNameTextBox" runat="server" Width="170px"></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="_firstNameRequired" runat="server" ControlToValidate="_firstNameTextBox"
                            CssClass="failureNotification" ErrorMessage="The First Name is manadatory!" ToolTip="The First Name is manadatory!"
                            ValidationGroup="ContactValidationGroup">*</asp:RequiredFieldValidator>
                    </td>
                    <td>
                        <asp:Literal ID="_lastNameLiteral" runat="server" Text="Last Name" />
                    </td>
                    <td>
                        <asp:TextBox ID="_lastNameTextBox" runat="server" Width="170px"></asp:TextBox>
                    </td>
                    <td>
                        <asp:RequiredFieldValidator ID="_lastNameRequired" runat="server" ControlToValidate="_lastNameTextBox"
                            CssClass="failureNotification" ErrorMessage="The Last Name is manadatory!" ToolTip="The Last Name is manadatory!"
                            ValidationGroup="ContactValidationGroup">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Literal ID="_phoneLiteral" runat="server" Text="Phone" />
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="_phoneTextBox" runat="server" Width="170px"></asp:TextBox>
                    </td>
                    <td>
                        <asp:Literal ID="_emailLiteral" runat="server" Text="Email" />
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="_emailTextBox" runat="server" Width="170px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Literal ID="_groupLiteral" runat="server" Text="Group" />
                    </td>
                    <td colspan="2">
                        <asp:DropDownList runat="server" ID="_groupDropDownList" EnableViewState="true" Width="170px">
                        </asp:DropDownList>
                    </td>
                    <td>
                        <asp:Literal ID="_noteLiteral" runat="server" Text="Note" />
                    </td>
                    <td colspan="2">
                        <asp:TextBox ID="_noteTextBox" runat="server" Width="170px" TextMode="MultiLine"
                            Height="80px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="6" style="text-align: center; padding-top: 8px; border-top: 2px; border-top-style: solid;
                        border-top-color: Gray; width: 100%" align="center">
                        <asp:Button ID="_saveButton" Text="Save" runat="server" Width="80px" ValidationGroup="ContactValidationGroup"
                            OnClick="_saveButton_Click" />
                        <asp:Button ID="_cancelButton" runat="server" autopostback="False" Width="80px" Text="Cancel"
                            OnClientClick='OnCancel();' />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Romania Romania
I have about 20 years experiences in leading software projects and teams and about 25 years of working experience in software development (SW Developer, SW Lead, SW Architect, SW PM, SW Manager/Group Leader).

Comments and Discussions