wzming2000 2015-10-17 03:07
浏览 614
已结题

DataList中用ItemCommand单击标题,出现字符串的格式不正确错误,求破解

DataList中用ItemCommand实现单击新闻标题,打开一个窗体显示新闻详细信息,以及实现分页功能。但是,分页中的上一页,下一页,首页末页都可实现,唯有点击新闻标题就会出现 输入字符串的格式不正确 的错误

我的代码是这样的:
protected void dlNews_ItemCommand(object source, DataListCommandEventArgs e)
{
switch (e.CommandName)
{
case "open":
int id = Convert.ToInt32(dlNews.DataKeys[e.Item.ItemIndex].ToString());
Response.Write("window.open('ShowNews.aspx?id=" + id + "','')");
break;
case "first":
ps.CurrentPageIndex = 0;
Bind(ps.CurrentPageIndex);
break;
case "pre":
ps.CurrentPageIndex = ps.CurrentPageIndex - 1;
Bind(ps.CurrentPageIndex);
break;
case "next":
ps.CurrentPageIndex = ps.CurrentPageIndex + 1;
Bind(ps.CurrentPageIndex);
break;
case "last":
ps.CurrentPageIndex = ps.PageCount - 1;
Bind(ps.CurrentPageIndex);
break;
case "search":
if (e.Item.ItemType == ListItemType.Footer)
{
int PageCount = int.Parse(ps.PageCount.ToString());
TextBox txtPage = e.Item.FindControl("txtPage") as TextBox;
int MyPageNum = 0;
if (!txtPage.Text.Equals(""))
MyPageNum = Convert.ToInt32(txtPage.Text.ToString());
if (MyPageNum <= 0 || MyPageNum > PageCount)
Response.Write("alert(&#39;请输入页数并确定没有超出总页数!&#39;)");
else
Bind(MyPageNum - 1);
}
break;
}

}
给出了这样的错误提示:
图片说明

    我是菜鸟,求大神帮帮忙看看啊
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作