vs2008开发wap网站的问题

tianshuishou tianshuishou 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我要开发一个wap网站。功能很简单,首页载入的时候显示一张姓名表,表的内容是datatable作成的。

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form ID="Form1" Runat="server">
<mobile:List ID="listData" Runat="server">
<DeviceSpecific>
<Choice Xmlns="http://schemas.microsoft.com/mobile/html32template">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>序号:</td>
<td>
<mobile:Label ID="lblID" Runat="server"><%# ++rowNum %></mobile:Label>
</td>
</tr>
<tr>
<td>名称:</td>
<td>
<mobile:Label ID="lblName" Runat="server">
<%#DataBinder.Eval(((MobileListItem)Container).DataItem, "Name")%></mobile:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</Choice>
</DeviceSpecific>
</mobile:List>
</mobile:Form>
</body>
</html>



using System;
using System.Web.UI.MobileControls;
using System.Data;

public partial class _Default : MobilePage
{
//行号
protected int rowNum = 0;

protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Rows.Add(new object[] { "小明" });
dt.Rows.Add(new object[] { "小红" });
dt.Rows.Add(new object[] { "小黄" });
dt.Rows.Add(new object[] { "小良" });

listData.DataSource = dt;
listData.DataBind();
}
}


一共有4条数据,按照预想,在首页应该显示:
序号:1
名称:小明
序号:2
名称:小红
序号:3
名称:小黄
序号:4
名称:小良

但显示的结果却是:
序号:5
名称:小明
序号:6
名称:小红
序号:7
名称:小黄
序号:8
名称:小良

似乎是<mobile:List>控件被绑定了两次。找了很久不知道什么原因,请高手指教!救命阿!
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部