I want to export UltraWebGrid data to Excel after a button click in my masterpage. The UltraWebGrid is located in a UltraWebTab Tab. I use the following code to find the grid control, which isn't working.
UltraWebGrid ultraWebGrid = (UltraWebGrid)tabSelected.FindControl("UltraWebGrid1");
The ultraWebGrid object is null. What am i doing wrong here?
Hello,
I am trying to reproduce the problem, unfortunately to no avail... when I get UltraWebGrid1 with FindControl() method I receive all values of control.
Could you please send a little bit more information about the UltraWebGrid declaration. ASPX, code-behind - anything that can get us started is welcome. And we try help you.
Our MasterPage (MasterVeras.master) contains a UltraWebTab Control (UltraWebTab1). Tab 1 calls a contentpage (R01.aspx) that has a different MasterPage (MasterContent.master). R01.aspx contains a UltraWebGrid (UltraWebGrid1).
MasterVeras.master contains an image button that has an onclick event below.
/// <summary> /// Export WebGrid data to Excel Sheet /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ImageButtonExcel_OnClick(object sender, EventArgs e) { Workbook oWorkbook = new Infragistics.Excel.Workbook();
Infragistics.WebUI.UltraWebTab.Tab tabSelected = UltraWebTab1.SelectedTabObject;
UltraWebGrid ultraWebGrid = (UltraWebGrid)tabSelected.FindControl("UltraWebGrid1"); UltraWebGridExcelExporter UltraWebGridExcelExporter = (UltraWebGridExcelExporter)tabSelected.FindControl("UltraWebGridExcelExporter1");
//todo debug: cannot locate objects using findcontrol if (UltraWebGridExcelExporter != null) { oWorkbook.Worksheets.Add("Data"); UltraWebGridExcelExporter.Export(ultraWebGrid, oWorkbook.Worksheets["Data"]); CreateExcelDocument(oWorkbook); } }
The tabSelected = correct. The FindControl both return null;