Results 1 to 2 of 2

Thread: Concatenate fields in datagrid

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Concatenate fields in datagrid

    The following code shows a bound coloumn in a datagrid called "ACTIONSTARTTIME". This displays something like "9" for 9 oclock or "24" for midnight.

    <asp:boundcolumn DataField="ACTIONSTARTTIME"
    HeaderText="Started"
    HeaderStyle-Width ="100"
    ReadOnly="true"
    Visible="True"/>

    I also want to concatenate the minutes held in a field called "ACTIONSTARTTIMEMINS" so that the bound coloumn looks like "9:15".

    Can someone tell me how I add the ":" and the field "ACTIONSTARTTIMEMINS".

    Thankyou

    Parksie

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Use a TemplateColumn instead of a BoundColumn:
    VB Code:
    1. <asp:TemplateColumn
    2.   HeaderText = "Start"
    3.   HeaderStyle-Width ="100">
    4.     <ItemTemplate>
    5.       <%# DataBinder.Eval ( Container.DataItem , "ACTIONSTARTTIME" )  +
    6.       ":" +
    7.       DataBinder.Eval ( Container.DataItem , "ACTIONSTARTTIMEMINS" ) %>
    8.     </ItemTemplate>
    9. </asp:TemplateColumn>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width