Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding one control into two places

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi all,

I'm reasonalbly new to .net so please forgive me.

I've got a database, that i am using a pagedatasouce to output the pagination. I looping over the number of pages using a for loop, and am then creating an htmlgenericcontrol li within it, and assigning it to a parent htmlgenericcontrol ul. once i am done with this, i am then adding the ul control to two panels within my aspx file, as i want the pagination to appear top and bottom. when i do this, i get no compile error or run time error, but i only get the one lot of pagination appearing at the bottom of the page (the last one to be added). i am assuming that the controls.add method is more of a pointer to the control rather than a physical copy this into that. does anyone know how i can get two outputs of this pagination to appear on the page?

this is my code:

Code:
  pnPagination_Top.Controls.Clear();
  pnPagination_Bottom.Controls.Clear();

  //create the html ul to hold the pagination
  HtmlGenericControl _ul = new HtmlGenericControl("ul");

  //loop over each 'page' and create a li and a link and then
  //add the control to the ul above
  for (int i = 0; i < _pds.PageCount; i++)
  {
    HtmlGenericControl _li = new HtmlGenericControl("li");

    LinkButton linkButton = new LinkButton();
    linkButton.ID = string.Format("PageNo{0}LinkButton", i);
    linkButton.Text = (i + 1).ToString();

    _li.Controls.Add(linkButton);
                    
    _ul.Controls.Add(_li);
  }

  pnPagination_Top.Controls.Add(_ul);
  pnPagination_Bottom.Controls.Add(_ul);

TIA

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top