I have developed an asp.net control that inherits from the gridview and its called gridviewex... i need some page navigation stuff to render underneath it for some custom paging that i am implenting.. All going well but i can't seem to add new controls to the controls..
For example what i wanted to do is add a asp.net Panel underneath the grid and than add linkbuttons to the panel.
I have this so far but it gives an error
Unable to cast object of type 'System.Web.UI.WebControls.Panel' to type
'System.Web.UI.WebControls.Table'.
The code..
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
Panel uxGridViewNavigation = new Panel();
LinkButton linkButton = null;
linkButton = new LinkButton();
linkButton.Text = "First";
linkButton.Click += new EventHandler(linkButton_Click);
uxGridViewNavigation.Controls.Add(linkButton);
this.Controls.Add(uxGridViewNavigation);
}
I would really appreciated any help. Its my first server control extension :-)
Thanks
Override Render
like:
override Render(HtmlTextWriter writer)
{
// outputs all the inner magic of your grid
base.Render(writer);
Panel panel = new Panel();
// do magic
// now also render the panel to the writer
panel.RenderControl(writer);
}