Ajax Master/Detail Page with the WebDataGrid - Code Behind

Craig Shoemaker / Thursday, November 06, 2008
   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.UI;
   6:  using System.Web.UI.WebControls;
   7:  using System.Web.Services;
   8:   
   9:  public partial class Demo_AJAXMasterDetail : System.Web.UI.Page
  10:  {
  11:      protected int index = 0;
  12:   
  13:      protected void Page_Load(object sender, EventArgs e)
  14:      {
  15:          if (!this.Page.IsPostBack)
  16:          {
  17:              this.dg.DataSource = BookRepository.Instance.GetBooks(5);
  18:              this.dg.DataBind();
  19:          }
  20:      }
  21:   
  22:      [WebMethod]
  23:      public static Book GetDetails(int id)
  24:      {
  25:          return BookRepository.Instance.GetByID(id);
  26:      }
  27:  }