帮助:位置0没有行 [英] help: there is no row at position 0

查看:77
本文介绍了帮助:位置0没有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我会弹出这个错误。我以前从来没遇到它,但我被告知是相当常见的



位置0没有行。

这是突出显示的代码块:

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
productId = Page.Request .QueryString [" product"];
popup = Page.Request.QueryString [" popup"];

Entity ent = Entity.GetEntity(" PRODUCTS");
DataRow dr = ent.GetInstances(BoostApplication.CurrentUser,BoostApplication.CurrentLanguage,""," PRD_ID =" + productId).Rows [0];

((mcTool.BasePage)Page)。PageHeading = dr [" PRD_NAME"]。ToString();
((mcTool.BasePage)Page)。PageTitle =" Page 1 - " + dr [" PRD_NAME"]。ToString()+" - 选择页面";
}



解决这个问题的最佳方法是什么,这个网站多年来一直在努力,任何想法为什么突然发生的事情

提前感谢


解决方案

找到了我只需要在if语句中包含块的答案:

if(ent.GetInstances(BoostApplication.CurrentUser,BoostApplication.CurrentLanguage) ,","" PRD_ID =" + productId).Rows.Count!= 0)
{


做任何事情();



}


Hi guys uim getting this error pop up. I've never come across it before but I've been told is fairly common

 

There is no row at position 0.

This is the block of code that is being highlighted:

protected override void OnInit(EventArgs e)
  {
 base.OnInit(e);
 productId = Page.Request.QueryString["product"];
 popup = Page.Request.QueryString["popup"];
 
 Entity ent = Entity.GetEntity("PRODUCTS");
 DataRow dr = ent.GetInstances(BoostApplication.CurrentUser, BoostApplication.CurrentLanguage, "", "PRD_ID=" + productId).Rows[0];
 
 ((mcTool.BasePage) Page).PageHeading = dr["PRD_NAME"].ToString();
 ((mcTool.BasePage) Page).PageTitle = "Page 1 - " + dr["PRD_NAME"].ToString() + " - Selection Page";
  }

 

what is the best way to fix this problem, this website has been up and ruuning for years, any ideas why this is suddenly happening

thanks in advance

 

解决方案

found the answer I just needed to encase the block in an if statement like so:

if (ent.GetInstances(BoostApplication.CurrentUser, BoostApplication.CurrentLanguage, "", "PRD_ID=" + productId).Rows.Count != 0)
 {

   do whatever();

 

}


这篇关于帮助:位置0没有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆