473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

c# PadRight Listbox Error

Hi I am having problems with using the padright function in ASP.NET. my code is

string listring;
string strTitle = ds.Tables["QueryT"].Rows[i]["Title"].ToString().Trim();
if (strTitle.Length > 15)
{
strTitle = strTitle.Remove(0,(strTitle.Length - 15));
}
else
{
strTitle = strTitle.PadRight(15, System.Convert.ToChar(" "));
}

liststring = strCallNo + " " + strTitle + strOpenDate + strCountry + strNotes + strStatusListItem listItem = new ListItem(liststring,ds.Tables["QueryT"].Rows[i] _["Call#"].ToString());

THe thing is this code works if i place a "*" instead of a space but when u use a space it doesnt appear as desired in the listbox yet i check the string before being inserted into the listbox and it is padded i.e

16574 erwerw*********19 but spaces it displays
16754 erwerw19

Thanks in advance

jimmy

--------------------------------
From: jimmy chao

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Oa8DbFNuyUSlAxzoThWZ3g==</Id>
Nov 16 '05 #1
1 3674
Jimmy,

You have to remember that you are ultimately viewing HTML code which has
certain rules about it, one of them is multiple spaces in a HTML tag. Try
the HTML space, &nbsp;, constant and see if that works for you.

HTH,

Matt
"jimmy chao via .NET 247" <an*******@dotnet247.com> wrote in message
news:uj**************@TK2MSFTNGP11.phx.gbl...
Hi I am having problems with using the padright function in ASP.NET. my code is
string listring;
string strTitle = ds.Tables["QueryT"].Rows[i]["Title"].ToString().Trim();
if (strTitle.Length > 15)
{
strTitle = strTitle.Remove(0,(strTitle.Length - 15));
}
else
{
strTitle = strTitle.PadRight(15, System.Convert.ToChar(" "));
}

liststring = strCallNo + " " + strTitle + strOpenDate + strCountry + strNotes + strStatusListItem listItem = new
ListItem(liststring,ds.Tables["QueryT"].Rows[i] _["Call#"].ToString());
THe thing is this code works if i place a "*" instead of a space but when u use a space it doesnt appear as desired in the listbox yet i check the
string before being inserted into the listbox and it is padded i.e
16574 erwerw*********19 but spaces it displays
16754 erwerw19

Thanks in advance

jimmy

--------------------------------
From: jimmy chao

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>Oa8DbFNuyUSlAxzoThWZ3g==</Id>

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: john sutor | last post by:
Is there something wrogn with this syntax? It does not put in the padded characters. string hk="Assembly"; hk.PadRight(35,'-'); this.textBox1.Text=hk + "Test"; The output is AssemblyTest
2
by: Allan Horwitz | last post by:
When I try to reference the lstproducts.selecteditem.value using autopostback from the lstproducts listbox I get an error? How can I fix my code to get the selected value from the lstproducts...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
3
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
7
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but...
2
by: Bill Nguyen | last post by:
I tried in vain to add blank space to the end of couple variables as below: mPadding = Convert.ToChar(" ") mdriverBegin.PadRight(16, mPadding) mdriverEnd.PadRight(16, mPadding) ...
4
by: Pascal | last post by:
hello i try to use padright and padleft to beautify the aspect of my prints. I 'd like the text to be print in two columns but i don't know the size of each string before (because they are...
3
by: MikeJ | last post by:
""NAME","SYSTEM_ID","TAX_ID","LICENSE""; the Above is one row read in from a text file its 38 bytes in width i want to pad this to 77 in my code padright is not working correctly unless i...
2
by: akshaycjoshi | last post by:
Refer the pic below, It's showing properly when seen in notepad but not in combobox. Here is the code OleDbDataReader trunkdr = trunkcom.ExecuteReader(); while (trunkdr.Read()) {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.