public void Page_Load(Object o, EventArgs e)
{
if (!IsPostBack)
{
ArrayList arr = new ArrayList();
arr.Add (new GroceryItem ("Bakery", "French Rolls", "On Sale"));
arr.Add (new GroceryItem ("Dairy", "Eggnog", "Half price"));
arr.Add (new GroceryItem ("Produce", "Apples", "A dollar a bushel"));
List1.DefaultCommand = "Default";
List1.MoreText = "Click for Details";
List1.DataSource = arr;
List1.DataBind ();
}
}
List1.DefaultCommand = "Default";
List1.MoreText = "Click for Details";这句显示在页面第一次加载时数据列表的右边,点击这
句会出现传统形式的具体页面.
1.在上面一句存在的情况下,这句如果没有的话,页面会用"更多"两个字代替"Click for Details".
2.在上面一句不存在的情况下,这句就算存在也没有任何作用,页面和传统的一样.
<mobile:ObjectList id="List1" runat="server"
LabelField="Item"
OnItemCommand="List1_Click">
<Command Name="Reserve" Text="Reserve"/>
<Command Name="Buy" Text="Buy"/>
</mobile:ObjectList>
1.这里面的<Command Name="Reserve" Text="Reserve"/>
<Command Name="Buy" Text="Buy"/>并不在首页显示,而是在点击某个具体数据后在另一个
详细页面出现.
2.这里面的OnItemCommand="List1_Click"主要对详细页面的命令选择情况进行判断,也就是说判断在这
个页面里,用户点击了哪个按钮,触发了哪个事件,实现详细页面中的命令点击的选择和处理.
<mobile:ObjectList id="List1" runat="server"
LabelField="Item"
OnItemCommand="List1_Click">
<Command Name="Reserve" Text="Reserve"/>
<Command Name="Buy" Text="Buy"/>
</mobile:ObjectList>
<mobile:ObjectList runat="server" id="CitiesList" AutoGenerateFields="false"
OnItemCommand="Cities_OnItemCommand" LabelField="CityName">
<Command Name="Forecast" Text="Long Range Forecast" />
</mobile:ObjectList>
注意里面的区别AutoGenerateFields="false",如果有这句,那一定要自设字段,如
<Field DataField="CityName" Title="城" />
<Field DataField="Condition" Title="状况" />
<Field DataField="High" Title="高" />
<Field DataField="Low" Title="低" />
<Field DataField="Forecast" Visible="False" />
<Field DataField="Forecast" Title="预报"/>
如果为true或默认的话,可以不用自设字段,系统为分配,但记录详细信息的字段是乱的.
如果设为true后又自设字段的话,刚都显示,也就是说页面会显示两遍记录的详细信息.