How do I concatenate 2 DataTable fields and bind them to a column?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdatagridrepeaterdatalist' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Bill Bassler
I've seen this done with templates, however can I apply a template to just
one column and leave to rest as asp:BoundColumns???

<asp:datagrid id="grid" runat="server" DataKeyField="AgreementMaster_ID"
font-names="verdana" font-size="x-small" BorderWidth="1" BorderColor="black"
BorderStyle="solid" GridLines="None" CellSpacing="2" CellPadding="2"
BackColor="white" CssClass="shadow" AutoGenerateColumns="false">
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<ItemStyle BackColor="Beige"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="Brown"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="CustomerName" HeaderText="Customer
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductLineType" HeaderText="Product
Line"></asp:BoundColumn>
<asp:BoundColumn DataField="StartTerms" HeaderText="Start
Terms"></asp:BoundColumn>

****************************************************************************
********
I'd like to add a column here with concatenated value of 2 database fields
e.g. first name + last name column
****************************************************************************
********
<asp:HyperLinkColumn Target="frInfo"
DataNavigateUrlField="AgreementMaster_ID"
DataNavigateUrlFormatString="WarrantyReport.aspx?id={0}"
DataTextField="AgreementMaster_ID" HeaderText="Details"
DataTextFormatString="Details on {0}">
<ItemStyle Font-Bold="True" BackColor="LightBlue"></ItemStyle>
</asp:HyperLinkColumn>
</Columns>
</asp:datagrid>

Reply to this message...
 
    
Marcie Jones (VIP)
Yep, you can just do one TemplateColumn, and leave the
rest as BoundColumns.

Datagrid Girl

--- Bill Bassler <Click here to reveal e-mail address> wrote:
[Original message clipped]

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

Reply to this message...
 
    
Bill Bassler
Just like the DataGrid Girl says:

you can just do one TemplateColumn, and leave the rest as BoundColumns.

<asp:datagrid id="grid" runat="server" DataKeyField="AgreementMaster_ID"
font-names="verdana" font-size="x-small" BorderWidth="1" BorderColor="black"
BorderStyle="solid" GridLines="None" CellSpacing="2" CellPadding="2"
BackColor="white" CssClass="shadow" AutoGenerateColumns="false">
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<ItemStyle BackColor="Beige"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="Brown"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="CustomerName" HeaderText="Customer
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductLineType" HeaderText="Product
Line"></asp:BoundColumn>
<asp:BoundColumn DataField="StartTerms" HeaderText="Start
Terms"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Warranty Period">
<ItemTemplate>
<asp:label id=Label2 style="MARGIN-LEFT: 5px; MARGIN-RIGHT: 5px"
runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Duration") + "
" + DataBinder.Eval(Container.DataItem, "DurationType") %>'>
</asp:label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="AgreementDate" HeaderText="Agreement
Date"></asp:BoundColumn>
<asp:HyperLinkColumn Target="frInfo"
DataNavigateUrlField="AgreementMaster_ID"
DataNavigateUrlFormatString="WarrantyReport.aspx?id={0}"
DataTextField="AgreementMaster_ID" HeaderText="Details"
DataTextFormatString="Details on {0}">
<ItemStyle Font-Bold="True" BackColor="LightBlue"></ItemStyle>
</asp:HyperLinkColumn>
</Columns>
</asp:datagrid>
"Marcie Jones" <Click here to reveal e-mail address> wrote in message
news:692408@aspngdatagridrepeaterdatalist...
[Original message clipped]

Reply to this message...
 
 
System.ComponentModel.Container
System.Web.UI.DataBinder
System.Web.UI.WebControls.BorderStyle
System.Web.UI.WebControls.BoundColumn
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.GridLines
System.Web.UI.WebControls.HyperLinkColumn
System.Web.UI.WebControls.TemplateColumn
System.Windows.Forms.BorderStyle
System.Windows.Forms.DataGrid




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com