using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class NestedGridView : System.Web.UI.Page
{
   int _pubId = 0;

protected void grdPublishers_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      int rowIndex = e.Row.DataItemIndex;
      int pubId = (int)grdPublishers.DataKeys[rowIndex].Value;

      // pobierz zagnieżdżoną kontrolkę nested gridview
      GridView grdBooks = (GridView)e.Row.FindControl("grdBookList");


      BookDA bda = new BookDA();
      DataTable books = bda.GetBooksByPublisher(pubId);
      grdBooks.DataSource = books;
      grdBooks.DataBind();
   }
}

}
