martes, 5 de agosto de 2014

El Libro del Día: Professional ASP.NET MVC 4

El Libro del Día: 2014-08-05

Titulo: Professional ASP.NET MVC 4
Autor: Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen
Editorial: Wrox
Nro Paginas: 507

Capítulos:
CHAPTER 1 Getting Started
CHAPTER 2 Controllers
CHAPTER 3 Views
CHAPTER 4 Models
CHAPTER 5 Forms and HTML Helpers
CHAPTER 6 Data Annotations and Validation
CHAPTER 7 Membership, Authorization, and Security
CHAPTER 8 Ajax
CHAPTER 9 Routing
CHAPTER 10 NuGet
CHAPTER 11 ASP.NET Web API
CHAPTER 12 Dependency Injection
CHAPTER 13 Unit Testing
CHAPTER 14 Extending MVC
CHAPTER 15 Advanced Topics
CHAPTER 16 Real-World ASP.NET MVC: Building the NuGet.org Website

Descarga:
Professional_ASPNET_MVC4

lunes, 4 de agosto de 2014

El Libro del Día: C# 5.0 All In One For Dummies

El Libro del Día: 2014-08-04

Titulo: C# 5.0 All In One For Dummies
Autor: Bill Sempf, Chuck Sphar, Stephen Randy Davis
Editorial: Wiley
Nro Paginas: 843

Capítulos:
Book I: The Basics of C# Programming
Chapter 1: Creating Your First C# Console Application
Chapter 2: Living with Variability - Declaring Value-Type Variables
Chapter 3: Pulling Strings
Chapter 4: Smooth Operators
Chapter 5: Getting into the Program Flow
Chapter 6: Lining Up Your Ducks with Collections
Chapter 7: Stepping through Collections
Chapter 8: Buying Generic
Chapter 9: Some Exceptional Exceptions
Book II: Object-Oriented C# Programming
Chapter 1: Object-Oriented Programming - What’s It All About?
Chapter 2: Showing Some Class
Chapter 3: We Have Our Methods
Chapter 4: Let Me Say This about this
Chapter 5: Holding a Class Responsible
Chapter 6: Inheritance: Is That All I Get?
Chapter 7: Poly-what-ism?
Chapter 8: Interfacing with the Interface
Chapter 9: Delegating Those Important Events
Chapter 10: Can I Use Your Namespace in the Library?
Chapter 11: Improving Productivity with Named and Optional Parameters
Book III: Designing for C#
Chapter 1: Writing Secure Code
Chapter 2: Accessing Data
Chapter 3: Fishing the FileStream
Chapter 4: Accessing the Internet
Chapter 5: Creating Images
Chapter 6: Programming Dynamically
Chapter 7: Helping Out with Interop
Book IV: A Tour of Visual Studio
Chapter 1: Getting Started with Visual Studio
Chapter 2: Using the Interface
Chapter 3: Customizing Visual Studio
Chapter 4: Transforming Text Templates
Book V: Windows Development with WPF
Chapter 1: Introducing WPF
Chapter 2: Understanding the Basics of WPF
Chapter 3: Data Binding in WPF
Chapter 4: Practical WPF
Book VI: Web Development with ASP.NET
Chapter 1: Looking at How ASP.NET Works with C#
Chapter 2: Building Web Applications
Chapter 3: Controlling Your Development Experience
Chapter 4: Leveraging the .NET Framework
Chapter 5: Digging into Web Construction
Book VII: Service-Oriented Development
Chapter 1: Getting Acquainted with Web Services
Chapter 2: Building Web Services with ASMX
Chapter 3: Building Web Services with WCF
Chapter 4: Building Web Services with REST

Descarga:
C#5.0_AllInOne_ForDummies

domingo, 3 de agosto de 2014

El Libro del Día: Professional jQuery

El Libro del Día: 2014-08-03

Titulo: Professional jQuery
Autor: Cesar Otero
Editorial: Wrox
Nro Paginas: 338

Capítulos:
PART I JQUERY FUNDAMENTALS
CHAPTER 1 Getting Started
CHAPTER 2 JavaScript Primer
CHAPTER 3 The jQuery Core
CHAPTER 4 DOM Element Selection and Manipulation
CHAPTER 5 Event Handling
CHAPTER 6 HTML Forms, Data, and Ajax
CHAPTER 7 Animations and Effects
PART II APPLIED JQUERY
CHAPTER 8 jQuery UI Part I - Making Things Look Slick
CHAPTER 9 jQuery UI Part II - Mouse Interactions
CHAPTER 10 Writing Effective jQuery Code
CHAPTER 11 jQuery Templates
CHAPTER 12 Writing jQuery Plugins
CHAPTER 13 Advanced Asynchronous Programming with jQuery Deferred
CHAPTER 14 Unit Testing with QUnit
APPENDIX Plugins Used In this Book

Descarga:
Professional_jQuery

sábado, 2 de agosto de 2014

El Libro del Día: Pro ASP.NET MVC 4

El Libro del Día: 2014-08-02

Titulo: Pro ASP.NET MVC 4 (4th Edition)
Autor: Adam Freeman
Editorial: Apress
Nro Paginas: 738

Capítulos:
Part 1: Introducing ASP.NET MVC 4
Chapter 1: What’s the Big Idea?
Chapter 2: Your First MVC Application
Chapter 3: The MVC Pattern
Chapter 4: Essential Language Features
Chapter 5: Working with Razor
Chapter 6: Essential Tools for MVC
Chapter 7: SportsStore - A Real Application
Chapter 8: SportsStore: Navigation
Chapter 9: SportsStore: Completing the Cart
Chapter 10: SportsStore: Administration
Chapter 11: SportsStore: Security & Finishing Touches
Part 2: ASP.NET MVC 4 in Detail
Chapter 12: Overview of MVC Projects
Chapter 13: URL Routing
Chapter 14: Advanced Routing Features
Chapter 15: Controllers and Actions
Chapter 16: Filters
Chapter 17: Controller Extensibility
Chapter 18: Views
Chapter 19: Helper Methods
Chapter 20: Templated Helper Methods
Chapter 21: URL and Ajax Helper Methods
Chapter 22: Model Binding
Chapter 23: Model Validation
Chapter 24: Bundles and Display Modes
Chapter 25: Web API
Chapter 26: Deployment

Descarga:
Pro_ASPNET_MVC4

viernes, 1 de agosto de 2014

El Libro del Día: Beginning ASP.NET 4.5.1 in C# and VB

El Libro del Día: 2014-08-01

Titulo: Beginning ASP.NET 4.5.1 in C# and VB
Autor: Imar Spaanjaars
Editorial: Wrox
Nro Paginas: 868

Capítulos:
Chapter 1 Getting started with ASP.NET 4.5.1
Chapter 2 Building an ASP.NET Website
Chapter 3 Designing Your Web Pages
Chapter 4 Working with ASP.NET Server Controls
Chapter 5 Programming Your ASP.NET Web Pages
Chapter 6 Creating Consistent Looking Websites
Chapter 7 Navigation
Chapter 8 User Controls
Chapter 9 Validating User Input
Chapter 10 ASP.NET AJAX
Chapter 11 jQuery
Chapter 12 Introducing Databases
Chapter 13 Displaying and Updating Data
Chapter 14 LINQ and the ADO.NET Entity Framework
Chapter 15 Working with Data - Advanced Topics
Chapter 16 Security in Your ASP.NET Website
Chapter 17 Personalizing Websites
Chapter 18 Exception Handling, Debugging, and Tracing
Chapter 19 Deploying Your Website
Appendix A Exercise Answers
Appendix B Configuring SQL Server 2012

Descarga:
2014_08_01_Beginning_ASPNET_4.5.1_C#_VB

jueves, 31 de julio de 2014

El Libro del Día: Beginning Windows 8 Application Development

El Libro del Día: 2014-07-31

Titulo: Beginning Windows 8 Application Development
Autor: István Novák, György Balássy, Zoltán Arvai, Dávid Fülöp
Editorial: Wrox
Nro Paginas: 626

Capítulos:
Part I: INTRODUCTION TO WINDOWS 8 APPLICATION DEVELOPMENT
Chapter 1: A BRIEF HISTORY OF WINDOWS APPLICATION DEVELOPMENT
Chapter 2: USING WINDOWS 8
Chapter 3: WINDOWS 8 ARCHITECTURE FROM A DEVELOPER’S POINT OF VIEW
Chapter 4: GETTING TO KNOW YOUR DEVELOPMENT ENVIRONMENT
Part II: CREATING WINDOWS 8 APPLICATIONS
Chapter 5: PRINCIPLES OF MODERN WINDOWS APPLICATION DEVELOPMENT
Chapter 6: CREATING WINDOWS 8 STYLE APPLICATIONS WITH HTML5, CSS, AND JAVASCRIPT
Chapter 7: USING XAML TO CREATE WINDOWS 8 STYLE USER INTERFACES
Chapter 8: WORKING WITH XAML CONTROLS
Chapter 9: BUILDING WINDOWS 8 STYLE APPLICATIONS
Chapter 10: CREATING MULTI-PAGE APPLICATIONS
Chapter 11: BUILDING CONNECTED APPLICATIONS
Chapter 12: LEVERAGING TABLET FEATURES
Part III: ADVANCING TO PROFESSIONAL WINDOWS 8 DEVELOPMENT
Chapter 13: CREATING WINDOWS 8 STYLE APPLICATIONS WITH C++
Chapter 14: ADVANCED PROGRAMMING CONCEPTS
Chapter 15: TESTING AND DEBUGGING WINDOWS 8 APPLICATIONS
Chapter 16: INTRODUCING THE WINDOWS STORE
Part IV: APPENDICES
Appendix A: ANSWERS TO EXERCISES
Appendix B: USEFUL LINKS

Descarga:
Beginning_Windows8_Application_Development

miércoles, 30 de julio de 2014

El Demo del Día: Paginar y Ordenar en el Control Web Repeater

Paginar y Ordenar en el Control Web Repeater

Requerimiento

Se desea crear una Aplicación Web que permita listar los datos de los empleados que cumpla con lo siguiente:
- Presente en columnas la información del código, apellido, nombre, fecha de nacimiento y foto del empleado.
- La cabecera de la grilla debe estar combinada de tal forma que muestre un titulo que diga Nombre Completo que agrupe al Apellido y al nombre del empleado.
- Las filas de datos deben tener un estilo con fondo blanco y color de letra azul, pero al pasar el mouse el estilo de la fila debe tener fondo amarillo y color de letra rojo.
- Lo principal es que muestre solo unos cuantos registros (por ejemplo 4), de tal forma que ocupe menos de una pagina.
- También debe permitir ordenar la información ascendente o descendente por cualquiera de las columnas creadas, mostrando un símbolo de ordenación en el ultimo campo ordenado.

Solución

Usaremos el Control Web Repeater y crearemos 2 tipos de paginación: con botones (primero, anterior, siguiente y último) y con Enlaces (Links con los números de paginas, al estilo GridView). Además usando plantillas agregaremos controles LinkButton para cada columna de tal forma que permita ordenar y mostraremos el símbolo de ordenación del último campo ordenado.

Nota: Para este caso, No podremos deshabilitar el ViewState debido ha que el Repeater tendrá LinkButtons que ejecutan código en el servidor y se perderían si deshabilitamos el ViewState. Pero como el control está paginado, no es mucho HTML el que se guarda en el cliente.

Crear el Procedimiento Almacenado en la Base de Datos de SQL Server

Usaremos la tabla Empleados (Employees) de Northwind:

Create Procedure [dbo].[uspEmployeesListar]
As
Select EmployeeID,LastName,FirstName,
IsNull(BirthDate,'1/1/1900') As BirthDate
From Employees Order By 1

Crear una Librería de Clases con las Entidades del Negocio

Crear un proyecto de tipo Librería de Clases en C# llamado: "Northwind.Librerias.EntidadesNegocio" y modificar el código de la clase como sigue:

using System;
namespace Northwind.Librerias.EntidadesNegocio
{
    public class beEmpleado
    {
        public int IdEmpleado { get; set; }
        public string Apellido { get; set; }
        public string Nombre { get; set; }
        public string NombreCompleto
        {
            get
            {
                return (String.Format("{0} {1}",Nombre,Apellido));
            }
        }
        public DateTime FechaNacimiento { get; set; }
    }
}

Crear una Librería de Acceso a Datos

Crear un proyecto de tipo Librería de Clases en C# llamado: "Northwind.Librerias.AccesoDatos" y modificar el código de la clase como sigue:

using System;
using System.Data; //CommandType
using System.Data.SqlClient; //SqlConnection, SqlCommand, SqlDataReader
using System.Collections.Generic; //List
using Northwind.Librerias.EntidadesNegocio; //beEmpleado
namespace Northwind.Librerias.AccesoDatos
{
    public class daEmpleado
    {
        public List<beEmpleado> listar(SqlConnection con)
        {
            List<beEmpleado> lbeEmpleado = null;
            SqlCommand cmd = new SqlCommand("uspEmployeesListar", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader drd = cmd.ExecuteReader(CommandBehavior.SingleResult);
            if (drd != null)
            {
                lbeEmpleado = new List<beEmpleado>();
                int posIdEmpleado = drd.GetOrdinal("EmployeeID");
                int posApellido = drd.GetOrdinal("LastName");
                int posNombre = drd.GetOrdinal("FirstName");
                int posFechaNacimiento = drd.GetOrdinal("BirthDate");
                beEmpleado obeEmpleado;
                while (drd.Read())
                {
                    obeEmpleado = new beEmpleado();
                    obeEmpleado.IdEmpleado = drd.GetInt32(posIdEmpleado);
                    obeEmpleado.Apellido = drd.GetString(posApellido);
                    obeEmpleado.Nombre = drd.GetString(posNombre);
                    obeEmpleado.FechaNacimiento = drd.GetDateTime(posFechaNacimiento);
                    lbeEmpleado.Add(obeEmpleado);
                }
                drd.Close();
            }
            return (lbeEmpleado);
        }
    }
}

Nota: Hay que hacer una referencia a la Librería de Entidades del Negocio.

Crear una Librería de Reglas del Negocio

Crear un proyecto de tipo Librería de Clases en C# llamado: "Northwind.Librerias.ReglasNegocio" y modificar el código de la clase como sigue:

using System;
using System.Configuration; //ConfigurationManager
namespace Northwind.Librerias.ReglasNegocio
{
    public class brGeneral
    {
        //Propiedad
        public string Conexion { get; set; }

        //Constructor
        public brGeneral()
        {
            Conexion = ConfigurationManager.ConnectionStrings["conNW"].ConnectionString;
        }
    }
}

Nota: Hay que hacer una referencia a la Librería de Entidades del Negocio, a la Librería de Acceso a Datos y a System.Configuration.

Agregar otra clase llamada: "brEmpleado" y escribir el siguiente código:

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using Northwind.Librerias.EntidadesNegocio;
using Northwind.Librerias.AccesoDatos;

namespace Northwind.Librerias.ReglasNegocio
{
    public class brEmpleado:brGeneral //Herencia
    {
        public List<beEmpleado> listar()
        {
            List<beEmpleado> lbeEmpleado = null;
            using (SqlConnection con = new SqlConnection(Conexion))
            {
                try
                {
                    con.Open();
                    daEmpleado odaEmpleado = new daEmpleado();
                    lbeEmpleado = odaEmpleado.listar(con);
                }
                catch (SqlException ex)
                {
                    //Capturar el error y grabar un Log
                }
            } //con.Close(); con.Dispose(); con = null;
            return (lbeEmpleado);
        }
    }
}

Nota: La clase "brEmpleado" hereda de la clase "brGeneral" la cadena de conexión para no pasarla como parámetro en cada método de la clase o en el constructor de cada clase se hace una sola vez.

Crear una Librería de Código de Usuario para Web

Crear un proyecto de tipo Librería de Clases en C# llamado: "General.Librerias.CodigoUsuarioWeb" y modificar el código de la clase como sigue:

using System;
using System.Collections.Generic;
using System.IO; //File
using System.Web; //HttpContext

namespace General.Librerias.CodigoUsuarioWeb
{
    public class Imagen
    {
        public static string obtenerUrl(int id, string carpeta)
        {
            string archivo = HttpContext.Current.Server.MapPath
            (String.Format("../Imagenes/{0}/{1}.jpg", carpeta, id));
            string url = String.Format("../Imagenes/{0}/{1}.jpg", carpeta, id);
            if (!File.Exists(archivo)) url = String.Format("../Imagenes/{0}/No.jpg", carpeta);
            return (url);
        }
    }
}

Nota: Como esta librería va a ser usada por paginas web hay que hacer referencia a: "System.Web"

Crear la Aplicación Web en ASP .NET Web Form

Crear un "Nuevo Sitio web vacío de ASP .NET" en C# llamado "Demo13" y crear las siguientes carpetas:
- Estilos: Para el archivo de hoja de estilo (CSS).
- Imagenes. Dentro crear otra carpeta llamada "Empleados" y adjuntar los archivos con las fotos de los empleados: 1.jpg, 2.jpg, 3.jpg, ... y No.jpg.
- Paginas: Para contener la pagina de lista de empleados.

Crear el Archivo de Hoja de Estilo (CSS)

Seleccionar la carpeta "Estilos" y agregar un archivo de hoja de estilos con el nombre de: "ACME.css" y modificar el código como sigue:

body {
    background-color:aqua;
}
.Titulo {
    background-color:black;
    color:white;
    text-transform:uppercase;
    font-size:xx-large;
    font-weight:bold;
}
.Subtitulo {
    background-color:white;
    color:blue;
    text-transform:capitalize;
    font-size:x-large;
    font-weight:bold;
}
.MarcarFila tr {
    background-color: white;
    color: blue;
    cursor:default;
    font-weight:normal;
}
.MarcarFila tr:hover {
    background-color: yellow;
    color: red;
    cursor:pointer;
    font-weight:bold;
}

Crear la Pagina ASP .NET como un Formulario Web Form

Seleccionar la carpeta "Paginas" y agregar un Formulario Web Form llamado: "ListaEmpleados.aspx", para empezar a diseñar la pagina hay que hacer referencia a las Librerías de Negocio (que copia todas sus dependencias) y la Librería de Código de Usuario Web.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListaEmpleados.aspx.cs" Inherits="Paginas_ListaEmpleados" %>
<%@ Import Namespace="Northwind.Librerias.EntidadesNegocio" %>
<%@ Import Namespace="General.Librerias.CodigoUsuarioWeb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="../Estilos/ACME.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
    </style>
</head>
<body class="Cuadro">
    <form id="form1" runat="server">
    <div>
        <table class="auto-style1">
            <tr>
                <td class="Titulo">Paginar y Ordenar en el Control Repeater</td>
            </tr>
            <tr>
                <td class="Subtitulo">Lista de Empleados</td>
            </tr>
            <tr>
                <td>
                    <asp:Repeater ID="rpEmpleado" runat="server">
                        <HeaderTemplate>
                            <table class="MarcarFila">
                                <tr style="text-align:center;background-color:lightgray;color:black">
                                    <td rowspan="2" style="width:100px">
                                        <%#obtenerSimbolo("IdEmpleado")%>
                                        <asp:LinkButton ID="lbnCodigo" Text="Código"
                                          OnClick="ordenarCampo"
                                          CommandArgument="IdEmpleado" runat="server" />
                                    </td>
                                    <td colspan="2" style="width:300px">Nombre Completo</td>
                                    <td rowspan="2" style="width:100px">
                                        <%#obtenerSimbolo("FechaNacimiento")%>
                                        <asp:LinkButton ID="lbnFechaNac" Text="Fecha Nac"
                                          OnClick="ordenarCampo"
                                          CommandArgument="FechaNacimiento" runat="server" />
                                    </td>
                                    <td rowspan="2" style="width:150px">Foto</td>
                                </tr>
                                <tr style="text-align:center;background-color:lightgray;color:black">
                                    <td style="width:150px">
                                        <%#obtenerSimbolo("Apellido")%>
                                        <asp:LinkButton ID="lbnApellido" Text="Apellido"
                                          OnClick="ordenarCampo"
                                          CommandArgument="Apellido" runat="server" />
                                    </td>
                                    <td style="width:150px">
                                        <%#obtenerSimbolo("Nombre")%>
                                        <asp:LinkButton ID="lbnNombre" Text="Nombre"
                                          OnClick="ordenarCampo"
                                          CommandArgument="Nombre"  runat="server" />
                                    </td>
                                </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%#((beEmpleado)Container.DataItem).IdEmpleado%>
                                </td>
                                <td>
                                    <%#((beEmpleado)Container.DataItem).Apellido%>
                                </td>
                                <td>
                                    <%#((beEmpleado)Container.DataItem).Nombre%>
                                </td>
                                <td>
                                    <%#((beEmpleado)Container.DataItem).FechaNacimiento.
                                            ToShortDateString()%>
                                </td>
                                <td>
                                    <img src='<%#Imagen.obtenerUrl(((beEmpleado)Container.DataItem).
                                      IdEmpleado,"Empleados")%>' width="120" height="80" alt="Foto"
                                      title="<%#((beEmpleado)Container.DataItem).NombreCompleto%>"/>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </td>
            </tr>
            <tr>
                <td style="text-align:center">
                    <asp:Button ID="btnPrimero" Text="<<" Width="50"
                      runat="server" OnClick="btnPrimero_Click" />
                    <asp:Button ID="btnAnterior" Text="<" Width="50"
                      runat="server" OnClick="btnAnterior_Click" />
                    <asp:TextBox ID="txtPosicion" Width="100" ReadOnly="true" runat="server" />
                    <asp:Button ID="btnSiguiente" Text=">" Width="50"
                      runat="server" OnClick="btnSiguiente_Click" />
                    <asp:Button ID="btnUltimo" Text=">>" Width="50"
                      runat="server" OnClick="btnUltimo_Click" />
                </td>
            </tr>
            <tr>
                <td id="celdaPaginas" style="text-align:center" runat="server">
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

El diseño de la pagina se mostrará como en la siguiente figura:


Escribir el siguiente código C# en la página:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Northwind.Librerias.EntidadesNegocio; //beEmpleado
using Northwind.Librerias.ReglasNegocio; //brEmpleado

public partial class Paginas_ListaEmpleados : System.Web.UI.Page
{
    private List<beEmpleado> lbeEmpleado;
    private string simbolo;
    private int registrosPagina = 4;
    private int indicePaginaActual;
    private int indiceUltimaPagina;

    protected void Page_Load(object sender, EventArgs e)
    {
        txtPosicion.Attributes.Add("style", "text-align:center");
        if (!Page.IsPostBack)
        {
            brEmpleado obrEmpleado = new brEmpleado();
            lbeEmpleado = obrEmpleado.listar();
            indiceUltimaPagina = (lbeEmpleado.Count / registrosPagina);
            if (lbeEmpleado.Count % registrosPagina == 0) indiceUltimaPagina--;
            ViewState["indicePaginaActual"] = indicePaginaActual;
            ViewState["indiceUltimaPagina"] = indiceUltimaPagina;
            Session["Empleados"] = lbeEmpleado;
            ViewState["campo"] = "";
            enlazarRepeater();
        }
        else
        {
            indiceUltimaPagina = (int)ViewState["indiceUltimaPagina"];
        }
        crearEnlacesPaginas();
    }

    private void crearEnlacesPaginas()
    {
        LinkButton lbn;
        for (int i = 0; i <= indiceUltimaPagina; i++)
        {
            lbn = new LinkButton();
            lbn.Text = (i + 1).ToString();
            lbn.Click += new EventHandler(paginar);
            celdaPaginas.Controls.Add(lbn);
            celdaPaginas.Controls.Add(new LiteralControl("  "));
        }
    }

    private void paginar(object sender, EventArgs e)
    {
        LinkButton lbn = (LinkButton)sender;
        indicePaginaActual = int.Parse(lbn.Text) - 1;
        ViewState["indicePaginaActual"] = indicePaginaActual;
        enlazarRepeater();
    }

    private void enlazarRepeater()
    {
        lbeEmpleado = (List<beEmpleado>)Session["Empleados"];
        List<beEmpleado> lbeFiltro = new List<beEmpleado>();
        int inicio = indicePaginaActual * registrosPagina;
        int fin = (indicePaginaActual * registrosPagina)+registrosPagina;
        for (int i = inicio; i < fin; i++)
        {
            if (i < lbeEmpleado.Count) lbeFiltro.Add(lbeEmpleado[i]);
            else break;
        }
        rpEmpleado.DataSource = lbeFiltro;
        rpEmpleado.DataBind();

        indicePaginaActual = (int)ViewState["indicePaginaActual"];
        indiceUltimaPagina = (int)ViewState["indiceUltimaPagina"];
        txtPosicion.Text = String.Format("{0} de {1}", indicePaginaActual + 1, indiceUltimaPagina + 1);
    }

    protected void ordenarCampo(object sender, EventArgs e)
    {
        LinkButton lbn = (LinkButton)sender;
        string campo = lbn.CommandArgument;
        ViewState["campo"] = campo;
        if (ViewState["simbolo"] == null) simbolo = "▲";
        else
        {
            if (ViewState["simbolo"].Equals("▲")) simbolo = "▼";
            else simbolo = "▲";
        }
        ViewState["simbolo"] = simbolo;
        lbeEmpleado = (List<beEmpleado>)Session["Empleados"];
        if(simbolo.Equals("▲")) lbeEmpleado = lbeEmpleado.OrderBy
            (x => x.GetType().GetProperty(campo).GetValue(x, null)).ToList<beEmpleado>();
        else lbeEmpleado = lbeEmpleado.OrderByDescending
            (x => x.GetType().GetProperty(campo).GetValue(x, null)).ToList<beEmpleado>();
        Session["Empleados"] = lbeEmpleado;
        enlazarRepeater();
    }

    protected string obtenerSimbolo(string campo)
    {
        if (ViewState["campo"].Equals(campo)) return (simbolo);
        else return ("");
    }

    protected void btnPrimero_Click(object sender, EventArgs e)
    {
        indicePaginaActual = 0;
        ViewState["indicePaginaActual"] = indicePaginaActual;
        enlazarRepeater();
    }

    protected void btnAnterior_Click(object sender, EventArgs e)
    {
        indicePaginaActual=(int)ViewState["indicePaginaActual"];
        if (indicePaginaActual > 0)
        {
            indicePaginaActual--;
            ViewState["indicePaginaActual"] = indicePaginaActual;
            enlazarRepeater();
        }
    }

    protected void btnSiguiente_Click(object sender, EventArgs e)
    {
        indicePaginaActual = (int)ViewState["indicePaginaActual"];
        indiceUltimaPagina = (int)ViewState["indiceUltimaPagina"];
        if (indicePaginaActual < indiceUltimaPagina)
        {
            indicePaginaActual++;
            ViewState["indicePaginaActual"] = indicePaginaActual;
            enlazarRepeater();
        }
    }

    protected void btnUltimo_Click(object sender, EventArgs e)
    {
        indiceUltimaPagina = (int)ViewState["indiceUltimaPagina"];
        indicePaginaActual = indiceUltimaPagina;
        ViewState["indicePaginaActual"] = indicePaginaActual;
        enlazarRepeater();
    }
}

Nota: Por defecto los registrosPorPagina está configurado a 4, pero se puede cambiar para probar, además el símbolo de ordenación ascendente es el caracter ASCII 30 y el descendente 31.

Modificar el Archivo Web.Config para especificar la cadena de conexión a Northwind

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="conNW" providerName="SQLServer" connectionString="uid=UsuarioNW;pwd=123456;
      data source=DSOFT\Sqlexpress; database=Northwind"/>
  </connectionStrings>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>
</configuration>

Probar la Pagina Web

Guardar el Sitio Web, clic derecho a la Pagina "ListaEmpleados.aspx" y seleccionar "Ver en el explorador".


Probar ir a cualquier pagina usando los Links con los números de paginas o con los botones, por ejemplo si estamos en la ultima ya no podemos avanzar a la siguiente o si estamos en la primera ya no podemos retroceder.

También ordenar los registros usando los Links de las cabeceras y ver el símbolo de ordenación que aparece, ya sea ascendente o descendente.

Comentario Final

En esta demostración hemos visto como podemos paginar sobre el control Repeater y como ordenar los registros mostrando el símbolo de ordenación. En el siguiente post, veremos como hacerlo en el control DataList.

Descarga:
Demo13_Paginar_Ordenar_Repeater