I have an asp:GridView which is bound. Within this I have multiple columns, I'm trying to get the data from two database fields concatenated into one field.
How to do this?
Something like this?
asp:BoundField DataField="field1 + ' ' + field2" HeaderText="Status" SortExpression="info"
                Answers. Use a TemplateField. In the ItemTemplate tag, you've to put html corresponding to your UI requirements. You can put 2 link buttons.
Start by adding a new TemplateField to the GridView by clicking on the Edit Columns link in the GridView's smart tag and adding a new TemplateField. Container. DataItem returns a DataRowView object corresponding to the DataSource record bound to the GridViewRow . Its Row property returns the strongly-typed Northwind.
The BoundField class is used by data-bound controls (such as GridView and DetailsView) to display the value of a field as text. The BoundField object is displayed differently depending on the data-bound control in which it is used.
My bind method Tables[0]. Columns) { TemplateField tField = new TemplateField(); tField. HeaderText = dc. ColumnName; GridView2.
Pretty sure you need to use a TemplateField instead of BoundField for this.
In your GridView Columns Block:
    <asp:TemplateField HeaderText="Name">
        <ItemTemplate>
            <%# Eval("FirstName") + " " + Eval("LastName")%>
        </ItemTemplate>
    </asp:TemplateField>
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With