I am creating a RadGrid from code behind. The MasterTable carries a template column with an Export button to export the underlying DetailsTable. The DetailsTable is not expanded by default. It only expands when (>) is clicked on the MasterTable.
The problem is Export doesnt work as it should. It exports the data from the MasterTable and not the DetailsTable.
Here is some portion of my code:
.....
Creating RadGrid1...
Creating a Master Table.....
Adding template column...
TemplateColumn = new GridTemplateColumn();
string ExportColumnName = "Export";
TemplateColumn.ItemTemplate = new MyExportTemplate(ExportColumnName);
TemplateColumn.HeaderText = ExportColumnName;
RadGrid1.MasterTableView.Columns.Add(TemplateColumn);
Creating a Details table....
...
Add everything to a RadAjaxPanel on the page.
.....
public class MyExportTemplate : ITemplate
{
private string colname;
public MyExportTemplate(string cName)
{
colname = cName;
}
public void InstantiateIn(System.Web.UI.Control container)
{
RadButton REB = new RadButton();
REB.Text = "Print Report";
REB.Click += REB_Click;
container.Controls.Add(REB);
}
void REB_Click(object sender, EventArgs e)
{
GridTableView table = ((sender as RadButton).NamingContainer as GridItem).OwnerTableView;
table.ExportToPdf();
}
}
The problem is Export doesnt work as it should. It exports the data from the MasterTable and not the DetailsTable.
Here is some portion of my code:
.....
Creating RadGrid1...
Creating a Master Table.....
Adding template column...
TemplateColumn = new GridTemplateColumn();
string ExportColumnName = "Export";
TemplateColumn.ItemTemplate = new MyExportTemplate(ExportColumnName);
TemplateColumn.HeaderText = ExportColumnName;
RadGrid1.MasterTableView.Columns.Add(TemplateColumn);
Creating a Details table....
...
Add everything to a RadAjaxPanel on the page.
.....
public class MyExportTemplate : ITemplate
{
private string colname;
public MyExportTemplate(string cName)
{
colname = cName;
}
public void InstantiateIn(System.Web.UI.Control container)
{
RadButton REB = new RadButton();
REB.Text = "Print Report";
REB.Click += REB_Click;
container.Controls.Add(REB);
}
void REB_Click(object sender, EventArgs e)
{
GridTableView table = ((sender as RadButton).NamingContainer as GridItem).OwnerTableView;
table.ExportToPdf();
}
}