点击链接后产生的问题如下:
索引 0 不是非负数且小于总行数。
说明: 执行当前 web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: system.indexoutofrangeexception: 索引 0 不是非负数且小于总行数。
源错误:
行 26: <asp:label id="label4" style="z-index: 107; left: 280px; position: absolute; top: 168px" runat="server" 行 27: width="48px" height="32px">项目号</asp:label> 行 28: <asp:label id=xm_name style="z-index: 106; left: 368px; position: absolute; top: 112px" runat="server" width="121px" height="32px" text=<%# databinder.eval(dataview1, "[0].xm_name", "{0}") %>> 行 29: </asp:label> 行 30: <asp:textbox id="textbox1" style="z-index: 101; left: 64px; position: absolute; top: 48px" runat="server" |
偶的主要源代码如下:
using system;
using system.collections;
using system.componentmodel;
using system.data;
using system.drawing;
using system.web;
using system.web.sessionstate;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.htmlcontrols;
namespace test8
{
/// <summary>
/// webform1 的摘要说明。
/// </summary>
public class webform1 : system.web.ui.page
{
protected system.web.ui.webcontrols.label label1;
protected system.web.ui.webcontrols.textbox textbox1;
protected system.web.ui.webcontrols.button button1;
protected system.data.oledb.oledbdataadapter oledbdataadapter1;
protected system.data.oledb.oledbcommand oledbselectcommand1;
protected system.data.oledb.oledbcommand oledbinsertcommand1;
protected system.data.oledb.oledbcommand oledbupdatecommand1;
protected system.data.oledb.oledbcommand oledbdeletecommand1;
protected system.data.oledb.oledbconnection oledbconnection1;
protected test8.dataset1 dataset11;
protected system.data.dataview dataview1;
protected system.web.ui.webcontrols.label label2;
protected system.web.ui.webcontrols.label label4;
protected system.web.ui.webcontrols.label label5;
protected system.web.ui.webcontrols.label label8;
protected system.web.ui.webcontrols.label xm_name;
protected system.web.ui.webcontrols.label xm_id;
protected system.web.ui.webcontrols.label jz_award;
protected system.web.ui.webcontrols.label xm_brief;
protected system.web.ui.webcontrols.datagrid datagrid1;
private void page_load(object sender, system.eventargs e)
{
}
此处省略web窗体设计器生成的代码
private void button1_click(object sender, system.eventargs e)
{
string sql_str1=textbox1.text;
if(textbox1.text!=””)
oledbdataadapter1.selectcommand.commandtext=”select * from t_ls_historyinfo where (xm_name like %” +sql_str1+”%)”;
oledbdataadapter1.fill(dataset11,”t_ls_historyinfo”);
datagrid1.datasource=dataset11.tables[“t_ls_historyinfo”].defaultview;
datagrid1.databind();
oledbconnection1.close();
}
private void datagrid1_selectedindexchanged(object sender, system.eventargs e)
{
oledbdataadapter1.fill(dataset11,”t_ls_historyinfo”);
int index = datagrid1.selectedindex;
string key = datagrid1.datakeys[index].tostring();
dataview1.rowfilter = datagrid1.datakeyfield + “=” + key + “”;
xm_name.databind();
xm_id.databind();
jz_award.databind();
xm_brief.databind();
}
}
}
问题出在那里呀?
焦急万分、、