balabommala
asked on
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.
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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
<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
ASKER
Thanks.
Glad to help :)
/signing off from MS Tech Ed
/signing off from MS Tech Ed
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)