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

RadGridView ToHtml() results missing column data

1 Answer 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Mar 2012, 10:51 PM
I am creating an exported Excel file from a RadGRidView via the ToHtml() method. However, some of the columns are missing data. Below is an example of two columns from the grid. The first (Description) results in valid data. The second (Coupon) has no data in the resultant Excel column:

                        <telerikGV:GridViewDataColumn UniqueName="Description"    IsReadOnly="True" Header="Description" Width="200">
                            <telerikGV:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <uc1:NextFocusTextBox Text="{Binding Path=Description}" IsReadOnly="True" Background="White" Height="22" />
                                    </Grid>
                                </DataTemplate>
                            </telerikGV:GridViewColumn.CellTemplate>
                        </telerikGV:GridViewDataColumn>


                        <telerikGV:GridViewDataColumn UniqueName="Coupon"         IsReadOnly="True" Header="Coupon (%/yr)" Width="95">
                            <telerikGV:GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <uc1:NextFocusTextBox Text="{Binding Path=Bond.Coupon, Converter={StaticResource ValueConverterNumericDash}, ConverterParameter=0:N3}" BorderThickness="0" IsReadOnly="True" IsEnabled="{Binding IsEnabled}" />
                                    </Grid>
                                </DataTemplate>
                            </telerikGV:GridViewColumn.CellTemplate>
                        </telerikGV:GridViewDataColumn>



The code behind to produce the results is:

private void mbToolBar_ExcelExportClicked(object sender, EventArgs e)
{
    _printFileName                = "some_location" + MainPage.Username + ".xls";

    Uri uri                       = new Uri(_wcf.InnerChannel.Via.AbsoluteUri.Replace(_wcf.InnerChannel.Via.AbsolutePath, "/PrintHandler.aspx?FileName=" + _printFileName));

    WebClient client              = new WebClient();

    client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadExcelCompleted);

    client.UploadStringAsync(uri, BondGrid.ToHtml());

    BondGrid.IsBusy               = true;
}

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Mar 2012, 08:02 AM
Hello,

 The grid cannot export columns with defined CellTemplate. You should handle ElementExporting and assign e.Value to desired for these columns similar to our exporting demo. 

Kind regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or