c# PadRight Listbox Error

  • Thread starter Thread starter jimmy chao via .NET 247
  • Start date 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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top