You can attach the event handler to your sub-GridView
s programmatically in that same loop (where you are binding data to them). Note that this assumes you want to handle them all with the same function:
for(counter = 0 ; counter < ds_news_details.Tables[0].Rows.Count; counter++)
{
GridView gv_pic = (GridView)GridView1.Rows[counter].FindControl("GridView2");
// Attach event handler here
gv_pic.PageIndexChanging += yourEventHandlerName;
ds_pic_preview = BL_News.News_Pictures_Select(Convert.ToInt32(ds_news_details.Tables[0].Rows[counter][0].ToString()));
gv_pic.DataSource = ds_pic_preview;
gv_pic.DataBind();
}
Where "yourEventHandlerName" is the name of the function that you want to use as the PageIndexChanging event handler:
protected void yourEventHandlerName(Object sender, GridViewPageEventArgs e)
{
}
You can cast the "sender" variable back to a GridView to examine it and figure out which sub-GridView
fired the event, I imagine. Something like this should work:
GridView currentGrid = (GridView)sender;