c# PadRight Listbox Error

  • Thread starter jimmy chao via .NET 247
  • Start date
J

jimmy chao via .NET 247

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

string listring;
string strTitle = ds.Tables["QueryT"].Rows["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 _["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
 
M

Matt

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,  , constant and see if that works for you.

HTH,

Matt
jimmy chao via .NET 247 said:
Hi I am having problems with using the padright function in ASP.NET. my code is

string listring;
string strTitle = ds.Tables["QueryT"].Rows["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 _["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
 
Top