Binding GridView to an Object Array
I have a class called User which contains a field called Department which is another class.
In the databinding I have the following :
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" Width="366px" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="PersonID" InsertVisible="False"
ReadOnly="True" SortExpression="UserID" />
<asp:BoundField DataField="Department.Name" HeaderText="Department Name" SortExpression="Department.Name" />
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderTemplate>
</HeaderTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
It successfully displays the data during databinding and have the department name displayed correctly.
The problem I have is during sorting. When I try to sort the DepartmentName field it says it cannot find the field named Department.Name.
How can I resolve this?
Note during binding I set the datasource of the grid to the User[] object.
"Dont you ever give up!"
__________________
\"Dont you ever give up!\"
|