Solved

escape characters won't work why?

Posted on 2006-06-24
9
230 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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
 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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