H
hazz
A treeview control should be able to select various aspx pages in the site.
(using sitemap)
One content page will have a gridview, accessed through a content place
holder while another aspx page will contain a report viewer, accessed
through the same contentplaceholder. At least that is how I understand it.
If I want the master page to contain a button to create an excel file from
the gridview contents, how do I access the gridview on the aspx page
containing the gridview? Findcontrol isn't finding the GridView as per;
protected void buttonCreateExcel_Click(object sender, EventArgs e)
{
// get control from aspx page that contains the GridView and
MasterPageFile="~/MasterPage.master"
Control myControl1 = FindControl("GridView1"); //returns
null unfortunately
if (myControl1 != null)
{
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Thank you,
-Greg
(using sitemap)
One content page will have a gridview, accessed through a content place
holder while another aspx page will contain a report viewer, accessed
through the same contentplaceholder. At least that is how I understand it.
If I want the master page to contain a button to create an excel file from
the gridview contents, how do I access the gridview on the aspx page
containing the gridview? Findcontrol isn't finding the GridView as per;
protected void buttonCreateExcel_Click(object sender, EventArgs e)
{
// get control from aspx page that contains the GridView and
MasterPageFile="~/MasterPage.master"
Control myControl1 = FindControl("GridView1"); //returns
null unfortunately
if (myControl1 != null)
{
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Thank you,
-Greg