View Single Post
  #4 (permalink)  
Old January 8th, 2007, 11:00 AM
hpox hpox is offline
Authorized User
Join Date: Dec 2006
Location: Montreal, Quebec, Canada.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts

I'm posting this message in case it can be of help to anybody searching for a similar solution.

Our solution was to 1) Instanciate our object in the code-behind file of the aspx page. 2) Get the GridView of our control by using the FindControl() method. 3) Bind the instanciated object as the DataSource of the GridView. Doing that permit us to have our BLL object with the necessary info. The drawback is that the Control is not self-contained. Everyone that wants to use the control must use a similar procedure to bind the DataSource.

Note that since the DataSourceId of the control is not set, we had to manually implement the page change method into the code-behind of the control because it would throw an exception about PAGE INDEX CHANGING everytime we clicked on the 1 2 3 4 5 ... links.

protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
   gridView.PageIndex = e.NewPageIndex;