D
dachrist28
I am trying to populate a listbox with data that is pulled from a sql
query. Here is my C# code behind the page:
sqlConn1.Open();
SqlCommand sqlComm2 = new SqlCommand("SElECT
replace((mc.MAINTENT.id + space(20-len(mc.maintent.id))+
left(mc.MAINTENT.aenm,50) +
space(50-len(left(mc.maintent.aenm,50)))+mc.mtntype.id),' ',' ') as
Description, mc.maintent.mtnoi FROM mc.MAINTENT INNER JOIN mc.MTNTYPE
ON mc.MAINTENT.mtctyp_oi = mc.MTNTYPE.mtoi WHERE (mc.MAINTENT.id >=
'F92') AND (mc.MAINTENT.aenm LIKE '%%') AND (mc.MTNTYPE.id LIKE '%%')
ORDER BY mc.MAINTENT.id", sqlConn1);
SqlDataReader sqlRead2 = sqlComm2.ExecuteReader();
lbEntities.DataSource = sqlRead2;
lbEntities.DataTextField = "Description";
lbEntities.DataValueField = "mtnoi";
lbEntities.DataBind();
sqlConn1.Close();
As you can see, I want to have white spaces in my listbox so the
columns appear nicely. I am replacing the spaces with   in my
query. The problem is that when the listbox displays, rather than
spaces I get etc. How do I pass the   from the query
to display the correct spaces in my listbox?
query. Here is my C# code behind the page:
sqlConn1.Open();
SqlCommand sqlComm2 = new SqlCommand("SElECT
replace((mc.MAINTENT.id + space(20-len(mc.maintent.id))+
left(mc.MAINTENT.aenm,50) +
space(50-len(left(mc.maintent.aenm,50)))+mc.mtntype.id),' ',' ') as
Description, mc.maintent.mtnoi FROM mc.MAINTENT INNER JOIN mc.MTNTYPE
ON mc.MAINTENT.mtctyp_oi = mc.MTNTYPE.mtoi WHERE (mc.MAINTENT.id >=
'F92') AND (mc.MAINTENT.aenm LIKE '%%') AND (mc.MTNTYPE.id LIKE '%%')
ORDER BY mc.MAINTENT.id", sqlConn1);
SqlDataReader sqlRead2 = sqlComm2.ExecuteReader();
lbEntities.DataSource = sqlRead2;
lbEntities.DataTextField = "Description";
lbEntities.DataValueField = "mtnoi";
lbEntities.DataBind();
sqlConn1.Close();
As you can see, I want to have white spaces in my listbox so the
columns appear nicely. I am replacing the spaces with   in my
query. The problem is that when the listbox displays, rather than
spaces I get etc. How do I pass the   from the query
to display the correct spaces in my listbox?