Inserting multiple columns of a datatable as a single column of a datagrid in ASP.NET

Hi,
Can we insert multiple columns of a datatable as a single column of a datagrid in ASP.NET?
Could you let me know how?

Thanks.
balabommalaAsked:
Who is Participating?
 
TheMegaLoserConnect With a Mentor Commented:
The SQL Case (note, column and table names are just invented since I dont know yours)

select adress +'<BR>' + city +'<BR>' + zipcode from companies

.NET case coming soon
0
 
TheMegaLoserCommented:
Sure you can. Either do it in the SQL query:

select firstname +', ' + lastname from names

Or do it with a column expression. See http://www.c-sharpcorner.com/Code/2003/May/AddingDataGridColumnToCal.asp for an example on expressions (The new datacolumn part)
0
 
balabommalaAuthor Commented:
Thanks for your quick reply.
I want the data columns to be added to the next line in the datagrid column
like this:

123 Peter Street
Chesapeake VA
02305

The above 3 lines are three columns in the table. But i wnat to show them as a single column in the datagrid as above.

Thanks
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
TheMegaLoserCommented:
I dont have access to a .NET environment atm but if you place a datagrid on a page, have a normal SQL query (selcet adress, zip, city) set the autogeneratecolumns property to false and add the following markup in the columns part of the datagrid I think it should work:

<asp:DataColumn HeaderText="Address" Expression="address + '<BR>' + city + '<BR' + zip">
</asp:DataColumn>


For more information on expressions, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp
0
 
balabommalaAuthor Commented:
Thanks.
0
 
TheMegaLoserCommented:
Glad to help :)

/signing off from MS Tech Ed
0
All Courses

From novice to tech pro — start learning today.