开发者

gridview databind

开发者 https://www.devze.com 2023-02-05 00:40 出处:网络
I\'m doing a gridview with an object datasource: List<MyObject> TheSource = a linq query At some point, I have

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 m开发者_StackOverflow社区ake 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.


<asp:TemplateField HeaderText="Full Name">
    <ItemTemplate>
        <span>
            <%# Eval("FirstName").ToString() +' '+ Eval("LastName").ToString()%>
         </span>
     </ItemTemplate>
 </asp:TemplateField>
0

精彩评论

暂无评论...
验证码 换一张
取 消