当我在实时网络服务器上打开我网站的特定页面时出现以下错误。
"名称为' imgURL'的字段未在所选数据源中找到。"
我在VS2010中使用ASP和C#。当我在本地开发和查看页面时,我没有收到错误消息。
两个实例都指向同一个远程数据库,并且正在执行相同的存储过程。当页面在网络服务器上运行时,我不明白为什么会收到此消息
我后面的代码中的函数调用存储过程来填充5个单选按钮列表。 对于一个单选按钮列表,我想在按钮上显示图像,因此我为什么要检索" imgURl"字段并尝试将其绑定到控件。在我本地电脑的调试中,我可以看到," ID"," DESC"和" imgURL"在var" resultslist"中,所以存储过程似乎确实返回了字段OK!
我显然很困惑为什么它在本地运行但不在主服务器上运行?
任何帮助非常感谢
protected void BindBookDetailsToRBLBox() {
ASPxRadioButtonList[] rblList = new ASPxRadioButtonList[5];
rblList[0] = rblInteriors;
rblList[1] = rblBind;
rblList[2] = rblPaper;
rblList[3] = rblLam;
rblList[4] = rblTrim;
// get the current radio button list box values.
// this is called each time the page loads or the control posts a change to its index
int[] bookDetailIDs = new int[] { 0, 0, 0, 0, 0 };
getSelectedRBLBoxValues(ref bookDetailIDs);
for (int i = 0; i < 5; i++)
{
int? returnCode = 0;
if (bookDetailIDs[i] == 0)
{
try
{
var resultsList = db.getValidCombos(RequiredData[i],
bookDetailIDs[0], bookDetailIDs[1],
bookDetailIDs[2], bookDetailIDs[3],
bookDetailIDs[4], ref returnCode).ToList();
// bind the data to the radio button list control
rblList[i].DataSource = resultsList;
rblList[i].ValueField = "ID";
if (i == 4)
rblList[i].ImageUrlField = "imgURL";
rblList[i].TextField = "DESC";
rblList[i].DataBind();
}
catch (SqlException ex)
{
Log_Error.AddToErrorLog("printingbooks.ascx.cs",
"BindBookDetailsToRBLBox", string.Empty, ex.Message);
}
}
}
}
答案 0 :(得分:0)
尝试使用以下
rblList[i].DataSource = resultsList.Select(x=> new{imgURL =x.imgURL, ID =x.ID}) ;