首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >单行Response.Write输出

单行Response.Write输出
EN

Stack Overflow用户
提问于 2014-01-03 12:57:38
回答 2查看 365关注 0票数 1

我试图在txt文件中的一行中输出网格视图中的数据,但是输出是多行的。

代码语言:javascript
复制
Dim str As New StringBuilder()

    For i = 0 To RowNo - 1

        str.Append("EDR,")
        str.Append(GridView1.Rows(i).Cells(9).Text)
        str.Append(",")
        str.Append("929110101,")
        str.Append(GridView1.Rows(i).Cells(8).Text)
        str.Append(",")
        str.Append("1,")
        str.Append(System.DateTime.DaysInMonth(Convert.ToInt32(GridView1.Rows(i).Cells(3).Text), Convert.ToInt32(GridView1.Rows(i).Cells(2).Text)))
        str.Append(",")
        str.Append(System.DateTime.DaysInMonth(Convert.ToInt32(GridView1.Rows(i).Cells(3).Text), Convert.ToInt32(GridView1.Rows(i).Cells(2).Text)))
        str.Append(",")
        str.Append(Convert.ToInt32(GridView1.Rows(i).Cells(7).Text))
        str.Append(",")
        str.Append(GridView1.Rows(i).Cells(5).Text)


    Next


    Response.Clear()

    Response.AddHeader("content-disposition", "attachment;filename=test.txt")

    Response.Charset = "ISO-8859-1"

    Response.Cache.SetCacheability(HttpCacheability.NoCache)

    Response.ContentType = "text/plain"

    Dim stringWrite As New System.IO.StringWriter()

    Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

    Response.Write(str.ToString())

    Response.[End]()

我的产出是那样的

EDR,000000000000005353291

1,9291101,10020108428318

1,31,31,7397,0

我需要的是

EDR,00000000000000005353291,929110101,10020108428318,1,31,31,7397,0

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-03 13:10:10

替换换行符。在VB.NET中,换行符由vbCr、vbLf常量表示。

str= str.Replace(vbCr, "").Replace(vbLf, "")

票数 2
EN

Stack Overflow用户

发布于 2014-01-03 13:04:03

你试过消毒绳子了吗?

代码语言:javascript
复制
myString = myString.Replace(Environment.NewLine,"")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20904202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档