0
votes

I am using devexpress and i want to set the selected gridview column visible = false, but i want that to appear on my csv as other name but with hyperlink on it after devexpress gridviewexporter download.

here is my code

<dx:ASPxButton ID="FeedbackGridBut" ClientIDMode="Static" runat="server" OnClick="FeedbackGridBut_Click" Text="Download" Image-Url="../images/excel.png"></dx:ASPxButton>

<dx:ASPxGridViewExporter GridViewID="FeedbackGrid" ID="exportFeedbackGrid" runat="server"></dx:ASPxGridViewExporter>
                            <dx:ASPxGridView ID="FeedbackGrid" ClientIDMode="Static" OnCustomUnboundColumnData="FeedbackGrid_CustomUnboundColumnData" ClientInstanceName="FeedbackGrid" runat="server" AutoGenerateColumns="False" CssClass="table table-striped" SettingsPager-Mode="ShowAllRecords" SettingsSearchPanel-Visible="True" DataSourceID="FeedbackDatasource" EnableCallBacks="true" SettingsBehavior-ProcessSelectionChangedOnServer="true" EnableRowsCache="False" SettingsBehavior-AutoExpandAllGroups="true" SettingsPopup-HeaderFilter-Height="400">
                                <Columns>
                                    <dx:GridViewDataTextColumn FieldName="sno" Visible="false">                                  
                                    </dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>

vb.net

 Protected Sub FeedbackGridBut_Click(sender As Object, e As EventArgs)
        exportFeedbackGrid.WriteXlsToResponse()
    End Sub

when i pressed the download all the column appeared except for the sno column, i dont want sno to appear on the webpage, i just want it to appear on the downloaded csv as other name as the sno value is too long and messy( for example: one of the value is asjdkgskfg-asdasd-asdasdasd) with hyperlink but it is not working.

1
Export the source data, not the GridView contents. And what is happening in exportFeedbackGrid.WriteXlsToResponse()? - VDWWD
but my gridview content is linked with the source data and exportFeedbackGrid.WriteXlsToResponse() is to export whatever data appeared on the gridview webpage - Kit
But why not export that data directly without using the GridView? Then you have full control over the data. - VDWWD
wait, seems like there is mistake on my question, i reedit the question. - Kit
done editing, do you have any idea on this? - Kit

1 Answers

0
votes

ASPxGridViewExporter by default will export columns depending on current grid's condition, including hidden columns. If you want to show hidden columns, just set their visibility immediately before using WriteXlsToResponse() method:

Protected Sub FeedbackGridBut_Click(sender As Object, e As EventArgs)
    exportFeedbackGrid.Columns("sno").Visible = True ' Set column state to visible
    ' Optional: exportFeedbackGrid.DataBind()
    exportFeedbackGrid.WriteXlsToResponse()
End Sub

The actual grid object will not changed because the grid properties has changed when triggers postback to return file.

References:

ASPxGridViewExporter - How to export hidden columns?

ASPxGridViewExporter - How to hide column during export (opposite from above)