ASP.Net DevExpress Gridview导出器CSV下载,带有指向网站的超链接链接

时间:2018-07-24 08:22:35

标签: asp.net vb.net devexpress

我正在使用 DevExpress Gridview导出器将Gridview导出为CSV ,我希望sno字段名称的行数据成为超链接,并且当我单击它时,它将显示

的网页
https://xxx?sno_id

该CSV随字段名称sno上的超链接一起导出,但是我不知道如何使它按我想要的方式工作。

我已经提到了这个site,但结果还是一样。

ASP.net

<dx:ASPxGridViewExporter GridViewID="FeedbackGrid" ID="exportFeedbackGrid" onrenderbrick="exportFeedbackGrid_RenderBrick" runat="server"> 
</dx:ASPxGridViewExporter>

     <dx:ASPxGridView ID="FeedbackGrid" ClientIDMode="Static" OnCustomUnboundColumnData="FeedbackGrid_CustomUnboundColumnData" ClientInstanceName="FeedbackGrid" runat="server" AutoGenerateColumns="False">
          <Columns>
               <dx:GridViewDataHyperLinkColumn FieldName="sno" Visible="false" PropertiesHyperLinkEdit-NavigateUrlFormatString="Http://{0}">                                
               </dx:GridViewDataHyperLinkColumn>
          </Columns></dx:ASPxGridView>

Vb.net

  Protected Sub FeedbackGridBut_Click(sender As Object, e As EventArgs)

        FeedbackGrid.Columns("sno").Visible = True
        exportFeedbackGrid.WriteXlsToResponse()

  End Sub

  Protected Sub ExportFeedbackGrid_RenderBrick(sender As Object, e As ASPxGridViewExportRenderingEventArgs) Handles exportFeedbackGrid.RenderBrick

      Dim dataColumn As GridViewDataColumn = e.Column As GridViewDataColumn 
        If Not e.RowType = GridViewRowType.Data And dataColumn Is Nothing Then
        e.TextValue = e.Value.ToString()
    End If

 End Sub

有人对此有想法吗?

1 个答案:

答案 0 :(得分:0)

我认为您想在列值上显示其他内容,但是它将创建带有sno列的超链接。我建议您检查以下参考资料:
Hyperlink Reference to another column DevExpress Gridview ASP.Net Webform

例如

GridViewDataHyperLinkColumn colItemName = new GridViewDataHyperLinkColumn();
    colItemName.FieldName = "sno";
    colItemName.PropertiesHyperLinkEdit.NavigateUrlFormatString = "~/details.aspx?Device={0}";
    colItemName.PropertiesHyperLinkEdit.TextFormatString = "{0}";
    colItemName.PropertiesHyperLinkEdit.TextField = "AnotherColumnFieldName";
    ASPxGridView1.Columns.Add(colItemName);

参考文献:
ASPxGridView - How to customize HyperLink column
How to create and configure a HyperLink column at runtime

如果没有帮助,请提供有关所需功能的更多详细信息。