Subgrouping using GridView
I am presenting data retrieved from the database using Gridview. The data is of the following form: clientCode order#
So any given client can have several orders. Is there a simple way to make sure that ClientCode is not repeated on every GridView row? I know I can programmatically compare each row to see if the clientCode has changed from the previous row, but this seems rather barbaric.
EDIT: I would actually prefer ONE row per client, and then several rows - one per order inside the client row. Not sure if it's possible without nesting GridView. Seems like an overkill.
in my aspx file i have
<asp:GridView ID="gvProjectData" runat="server" AllowPaging="true"
AutoGenerateColumns="false开发者_开发百科"
DataKeyNames="p_clientcd,p_orderno"
PageSize="10"
EmptyDataText="No data"
CssClass="gridview" >
<Columns>
<asp:BoundField DataField="p_clientcd" HeaderText="Client" ReadOnly="true" ></asp:BoundField>
<asp:BoundField DataField="p_orderno" HeaderText="Order #" ReadOnly="true"></asp:BoundField>
</Columns>
</asp:GridView>
Matt Berseth did something very similar to this using ListView.
精彩评论