我有一個由對象類填充的消息的網格視圖。對象中有一個列表,以便每個消息都有一個收件人列表。問題是,現在GridView只顯示每個消息的「Person []」。我希望它顯示爲列表中收件人的數量。使用對象列表填充gridview列
任何幫助,將不勝感激。
HTML
<asp:GridView
ID="grdMsgSent"
runat="server"
CssClass="cellSpacing"
OnRowDataBound="grdMsgSent_RowDataBound"
AllowSorting="True"
EmptyDataText="You have not sent any messages."
AllowPaging="True"
PageSize="6"
OnPageIndexChanging="grdMsgSent_PageIndexChanging"
OnSorting="grdMsgSent_Sorting"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="Recipients" HeaderText="Recipients" />
</Columns>
</asp:GridView>
C#
grdMsgSent.DataSource = listSentMsg.List;
grdMsgSent.DataBind();
添加評估和演示,我仍然得到了「Service.Person []」中的收件人列。我知道它不是一個空數組,因爲我使用服務客戶端來查看填充了正確數據的列表。 –
你必須這樣做:'Eval(「YourArray.Count」)'。 – afzalulh
我收到一條錯誤消息,告訴我我的數組不包含名爲'Count'的屬性。 –