Reputation: 52047
I'm doing a gridview with an object datasource:
List<MyObject> TheSource = a linq query
At some point, I have
MyGridview.DataSource = TheSource;
MyGridview.Databind();
and an OnRowDataBound event handler that's tied to the databinding.
In that event handler, how do you make column 2 contain 2 objects from TheSource. For instance, in the TheSource, there is a variable for FirstName and another one for LastName. Column 2 needs to contain both the first and last name in the same cell.
Thanks.
Upvotes: 1
Views: 443
Reputation: 27426
<asp:TemplateField HeaderText="Full Name">
<ItemTemplate>
<span>
<%# Eval("FirstName").ToString() +' '+ Eval("LastName").ToString()%>
</span>
</ItemTemplate>
</asp:TemplateField>
Upvotes: 1