Click here to Skip to main content
16,019,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi My Question is how to display data as one row and one column in list box
in my database i have a "Polygon" table with 7 columns .i suppose to retrieve one column as "PolygonCords".in this polygoncords i data stored in horizontal way
Like

select polygoncords from polygon where locatorid=1234;
polygoncords
-104.4328606353482,39.27509898079456,0 -104.4700309210515,39.86328676201262, etc


Now i want display this data in listbox (ASP.NET)(plz dont say use other controls),its mandatory.but the data is displayed in list box(as shown above in horizontal way)
i need same data display in vertical way ....IS IT POSSIBLE?
Posted
Updated 1-Jul-11 12:19pm
v2

If you could uses LINQ to SQL for the query then in would look like:

var query = 
    from m in dataContext.polygon
    where m.locatorid == 1234
    select m.polygoncords;

var listCords = query.ToList(); 

// Here you can transform the presentation of the data if desired
// FormatData would be a function that would take one polygoncords item
// and returns a string appropriatly formated.
var formatedResult = (
    from m2 in listCord
    select FormatData(m2)).ToList();

listbox.Items.AddRange(formatedResult);
 
Share this answer
 
Since you didn't specify language, this is in C# (VB would be very similar):

C#
string data = string.Format("{0} * {1} * {3}", dataItem1, dataItem2, dataItem3);
listbox.Items.Add(data)
 
Share this answer
 
Comments
Philippe Mori 1-Jul-11 20:37pm    
{3} should be {2}

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