Arindam Das
Arindam Das

Reputation: 699

how to get 2 data from database in one single cell of a gridview in asp.net?

i want to show 2 data from my sql server database in a single cell of a gridview, i have tried this :

<asp:GridView ID="engpodataGV1" runat="server" AutoGenerateColumns="False" Width="910px"
                            DataKeyNames="PONumber" OnSelectedIndexChanged="engpodataGV1_SelectionChanged">
<Columns>
 <asp:TemplateField HeaderText="Complition Time">
     <ItemTemplate>
      <asp:Label ID="Label8" runat="server" ForeColor="Black" Font-Bold="false" Text='<%# Eval("CompletionTime") + Eval("CompletionTimeFormat") %>'></asp:Label>
       </ItemTemplate>
       <ControlStyle Width="100px" />
       <ItemStyle BorderStyle="Solid" BorderWidth="1px" />
      </asp:TemplateField>
 </Columns>
</asp:GridView>

my query is that: is this the right way to do this? now i have tested it and i am getting error on + what to do?

Upvotes: 1

Views: 706

Answers (1)

Wiktor Zychla
Wiktor Zychla

Reputation: 48279

You don't really need the label, the item template accepts any markup. In particular, it could even be:

   <ItemTemplate>
       <%# Eval("CompletionTime") %>&nbsp;<%# Eval("CompletionTimeFormat") %>
   </ItemTemplate>

Upvotes: 2

Related Questions