This is a migrated thread and some comments may be shown as answers.

hierarchical data exporting to ExcelML

0 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bharat veer
Top achievements
Rank 1
bharat veer asked on 04 Aug 2011, 07:31 PM
Good Morning Sir,

I have a Parent Grid. in its Item Template i have two more grid. One For Country and second for states.
i bind both grid on the ItemDatabaound of the parent gird. both grid bound successfully bound.
below is the HTML how i put the grid.

<telerik:RadGrid ID="HeaderGrid" runat="server"
        onitemdatabound="HeaderGrid_ItemDataBound" >                    
       <MasterTableView>    
       <ItemTemplate>          
        <asp:Label ID="lblCountryID" runat="server" Visible="true" Text='<%#Eval("CountryID")%> '></asp:Label>      
         <telerik:RadGrid ID="CountryGrid" runat="server">
         </telerik:RadGrid>    
         <telerik:RadGrid ID="StateGrid" runat="server">
         </telerik:RadGrid>
       </ItemTemplate>
       </MasterTableView>
</telerik:RadGrid>


on item databound both grid are bind successfully.
 protected void HeaderGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.Item ||
            e.Item.ItemType == GridItemType.AlternatingItem)
        {
            int CountryID = Convert.ToInt32(((Label)e.Item.FindControl("lblCountryID")).Text);
            RadGrid CountryGrid= (RadGrid)e.Item.FindControl("CountryGrid");
            con = new SqlConnection("data source=(local);initial catalog=iTracker_DB;persist security info=True;user id=iTrackerUser;password=77Bcc333");
            cmd = new SqlCommand("select * from Country where CountryID = '" + CountryID + "' ", con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            con.Close();
            CountryGrid.DataSource = dt;
            CountryGrid.DataBind();

            RadGrid StateGrid= (RadGrid)e.Item.FindControl("StateGrid");
            con = new SqlConnection("data source=(local);initial catalog=iTracker_DB;persist security info=True;user id=iTrackerUser;password=77Bcc333");
            cmd = new SqlCommand("select * from State where CountryID = '" + CountryID + "' ", con);
            con.Open();
            SqlDataReader dr1 = cmd.ExecuteReader();
            DataTable dt1 = new DataTable();
            dt1.Load(dr1);
            con.Close();
            StateGrid.DataSource = dt1;
            StateGrid.DataBind();
        }
    }

when i export with this code
 HeaderGrid.ExportSettings.ExportOnlyData = true;
  HeaderGrid.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
only Country data is exported.
how state data can be exported.


please reply soon.

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
bharat veer
Top achievements
Rank 1
Share this question
or