Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using (SqlConnection con = new SqlConnection(CS))
            {
                con.Open();
                SqlCommand cmd2 = new SqlCommand("SELECT [Item_Name],[Order_ID],[Price] FROM [Work_Lab].[dbo].[ItemOrderDetails]", con);
                //SqlDataReader dr = cmd2.ExecuteReader();
                SqlDataAdapter ds = new SqlDataAdapter(cmd2);
                DataTable dt = new DataTable();
                ds.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    Response.Output.Write("--------------------------<br/>");
                    Response.Output.Write("|Item Name|Order No|Price&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|<br/>");
                    Response.Output.Write("--------------------------<br/>");
                    foreach (DataRow row in dt.Rows)
                    {
                        string name = "|"+Convert.ToString(row["Item_Name"]).PadRight(8)+"|";
                        string orderId = Convert.ToString(row["Order_ID"]).PadRight(5)+"|";
                        string price = row["Price"].ToString() + "|<br/>";
                        Response.Output.Write(name);
                        Response.Output.Write(orderId);
                        Response.Output.Write(price);
                    }
                    Response.Output.Write("--------------------------");
                }
                con.Close();
            }



here this is my code.

Problem is...
while i save Item_Name value in string with padding it surely added padding in it...
e.g.
Original value = "Pen";
with padding = "Pen "; (with 4 white space);

but while i print this value with Response.Output.Print it doesn't take that white space ...
it directly print value without any white space.

how i can add white space in it?

Hope you understand what i want to ask.
Posted
Comments
Michael_Davies 30-Jan-16 3:56am    
Possibly a font issue, what font is being used for printing?

Two basic kinds proportional and non-proportional, non-proportional each character fits in the same size space, proportional and the character is in a variable sized space and so prints a different length for the same characters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900