|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThe ASP.NET version 3.5
Using the codeThis
Other than the above extension public properties, the 1: <myControls:ListViewSort ID="listViewSort"
2: DataSourceID="ObjMenu"
3: DataKeyNames="Name"
4: SortExpressionDefault="Name"
5: SortDirectionDefault="Ascending"
6: runat="server">
7: <LayoutTemplate>
8: <table runat="server"
9: class="listViewGrid"
10: cellspacing="0"
11: border="0">
12: <tr>
13: <th>
14: <myControls:ListViewSortColumnHeader runat="server"
15: Key="Name"
16: Text="Food Name" />
17: </th>
18: <th>
19: <myControls:ListViewSortColumnHeader runat="server"
20: Key="Price"
21: Text="Price" />
22: </th>
23: <th>
24: <myControls:ListViewSortColumnHeader runat="server"
25: Key="Description"
26: Text="Description" />
27: </th>
28: <th>
29: <myControls:ListViewSortColumnHeader runat="server"
30: Key="Calories"
31: Text="Calories" />
32: </th>
33: </tr>
34:
35: <tr runat="server" id="itemPlaceholder" />
36:
37: </table>
38: <asp:DataPager ID="dataPager" runat="server">
39: <Fields>
40: <asp:NumericPagerField ButtonCount="10"
41: NextPageText="..."
42: PreviousPageText="..." />
43: </Fields>
44: </asp:DataPager>
45: </LayoutTemplate>
46: <ItemTemplate>
47: <tr class="<%# ((ListViewDataItem)Container).DisplayIndex % 2 == 0 ?
"itemRow" : "altItemRow" %>">
The The 1: protected override void OnDataBound(EventArgs e)
2: {
3: if (base.SortExpression.Length == 0)
4: {
5: if (SortExpressionDefault.Length > 0)
6: {
7: base.Sort(SortExpressionDefault, SortDirectionDefault);
8: }
9: }
10:
11: List<Control> controls = Helpers.GetControlsByType(this,
typeof(ListViewSortColumnHeader));
12: foreach (Control control in controls)
13: {
14: ListViewSortColumnHeader header = (ListViewSortColumnHeader)control;
15: if (header.HasSortDirectionIndicator() == true)
16: {
17: header.ResetSortDirectionIndicator();
18: }
19: }
20:
21: foreach (Control control in controls)
22: {
23: ListViewSortColumnHeader header = (ListViewSortColumnHeader)control;
24: if (header.Key == base.SortExpression)
25: {
26: header.SetSortDirectionIndicator(base.SortExpression,
base.SortDirection);
27: break;
28: }
29: }
30:
31: base.OnDataBound(e);
32: }
During the The project demo file for the above sample HTML and the code above also demonstrates the usage of an ASP.NET History
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||