Solved

escape characters won't work why?

Posted on 2006-06-24
9
229 Views
Last Modified: 2009-12-16
This should produce a nice table, but it does not work. It looks like escape characters not work. I print the text in an asp label.


private string GetTableData(DataTable dt)
    {

        StringBuilder TableData = new StringBuilder();
        // retrieve header row column labels
        TableData.AppendFormat("Row");
        foreach (DataColumn dc in dt.Columns)
        {
            TableData.AppendFormat("/t{0}", dc.ColumnName);
            TableData.AppendFormat("/t");
        }

        // retrieve rows
        int j = -1;
        foreach (DataRow dr in dt.Rows)
        {
            TableData.AppendFormat("[{0}]", ++j);
            foreach (DataColumn dc in dt.Columns)
            {
                TableData.AppendFormat("/t{0}", dr[dc]);
            }
            TableData.AppendFormat("/n");
        }

        return TableData.ToString();
    }
0
Comment
Question by:m-jansen
  • 5
  • 4
9 Comments
 
LVL 5

Expert Comment

by:AdGroot
ID: 16976421
use the \ in place of the /

Change /t  to \t
and /n to \n

Ad
0
 

Author Comment

by:m-jansen
ID: 16976427
sorry that does not work either
0
 
LVL 5

Expert Comment

by:AdGroot
ID: 16976442
Strange

I try this

            StringBuilder TableData = new StringBuilder();
            TableData.AppendFormat("AA\tKK\tBB");
            TableData.AppendFormat("\n");
            TableData.AppendFormat("AAB\tBBK\tKK");
            Debug.WriteLine(TableData.ToString());

with gives me as result

AA      KK      BB
AAB      BBK      KK
0
 

Author Comment

by:m-jansen
ID: 16976460
With this code
        StringBuilder TableData = new StringBuilder();
        TableData.AppendFormat("AA\tKK\tBB");
        TableData.AppendFormat("\n");
        TableData.AppendFormat("AAB\tBBK\tKK");
        lblTest.Text = TableData.ToString(); //asp lable
I get just this is the output.

AA KK BB AAB BBK KK

Debug.WriteLine(TableData.ToString()); does not work in my asp.net 2.0 website in VS
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Assisted Solution

by:AdGroot
AdGroot earned 50 total points
ID: 16976469
A supose the asp label have some problems with the tabs

you can try this

           TableData.AppendFormat("/t{0,10}", dc.ColumnName);

Ad

0
 
LVL 5

Expert Comment

by:AdGroot
ID: 16976475
For left align try

           TableData.AppendFormat("/t{0,-10}", dc.ColumnName);

Ad

0
 
LVL 5

Accepted Solution

by:
AdGroot earned 50 total points
ID: 16976491
For a newline you kan try to insert a <br> in TableData

Ad
0
 

Author Comment

by:m-jansen
ID: 16976500
It have problems with newline too. What to use instead of "\n"
0
 

Author Comment

by:m-jansen
ID: 16976511
thanks alot. so it's html I must use as reference when using escape characters in asp?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 4 160
Access properties in nested observable collections 8 23
VB.Net How to Exit Sub - Exit Form??? 5 51
What .NET URL re-routing tool did I use? 2 37
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now