using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public struct Book
{
    public string title
    {
        get;
        set;
    }
    public string author
    {
        get;
        set;
    }
}
public partial class _Default : System.Web.UI.Page
{
    protected List<Book> GridViewBooks
    {
        get
        {
            return (List<Book>)Session["Books"];
        }
        set
        {
            Session["Books"] = value;
        }
    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    }

    void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = GridViewBooks;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<Book> theBooks = new List<Book>();
            Book aBook = new Book();
            aBook.title = "First book title";
            aBook.author = "First book author";
            theBooks.Add(aBook);
            GridViewBooks = theBooks;
        }
    }

    protected void RadButton1_Click(object sender, EventArgs e)
    {
        List<Book> theBooks = new List<Book>();
        Book aBook = new Book();
        aBook.title = "Another title " + DateTime.Now.ToString();
        aBook.author = "another book author";

        theBooks = GridViewBooks;
        theBooks.Add(aBook);
        GridViewBooks = theBooks;

        RadGrid1.Rebind();
    }
}
