给分三十分,急呀!用户代码未处理 System.IndexOutOfRangeException Message="在位置 0 处没有任何行。"

cadwork 2008-06-04 08:08:43
public partial class Default2 : System.Web.UI.Page
{
string gid;
DataTable dtTable;
Hashtable hashCar;
string strSql;
WebService webService = new WebService();
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["gid"] != null)
strSql = "Update z_GoodsInfo set Goods_point=Goods_point+1 where Goods_ID='" + gid + "'";
webService.ExcuteSql(strSql);//保存到数据库中
strSql = "select * from z_GoodsInfo where Goods_ID='" + gid + " '";
dtTable = webService.ExcuteSelect(strSql);
this.lblGoodsName.Text = dtTable.Rows[0]["Goods_name"].ToString(); this.lblDesc.Text = dtTable.Rows[0]["Goods_orderDesc"].ToString();
this.Image1.ImageUrl = dtTable.Rows[0]["Goods_img"].ToString();
this.lblPoint.Text = dtTable.Rows[0]["Goods_point"].ToString();
this.lblAddDate.Text = dtTable.Rows[0]["Goods_addDate"].ToString();
this.lblGoodsMsg.Text = dtTable.Rows[0]["Goods_introduce"].ToString();
if (dtTable.Rows[0]["Goods_isSpecial"].ToString() == "y")
this.lblPrice.Text = "优惠价:$" + dtTable.Rows[0]["Goods_specialPrice"].ToString();
else
this.lblPrice.Text = "$" + dtTable.Rows[0]["Goods_price"].ToString();
this.lbtnBuy.CommandArgument = gid;
错误信息是:并用特殊颜色标注,用户代码未处理 System.IndexOutOfRangeException
Message="在位置 0 处没有任何行。"
Source="System.Data"
StackTrace:
在 System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
在 System.Data.RBTree`1.get_Item(Int32 index)
在 System.Data.DataRowCollection.get_Item(Int32 index)
在 Default2.Page_Load(Object sender, EventArgs e) 位置 f:\works of literature and art\ch21\User_GoodsInfo.aspx.cs:行号 28
在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
在 System.Web.UI.Control.OnLoad(EventArgs e)
在 System.Web.UI.Control.LoadRecursive()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
...全文
338 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunxw18 2008-06-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sz_free_bird 的回复:]
先确定DataTable里有没有数据。看看DataTable.Rows.Count的值
[/Quote]
DataTable.Rows.Count>0就绑定,否则提示
sz_free_bird 2008-06-04
  • 打赏
  • 举报
回复
先确定DataTable里有没有数据。看看DataTable.Rows.Count的值

62,040

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧