数据|数据库|问题|显示
点击链接后产生的问题如下:
索引 0 不是非负数且小于总行数。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.IndexOutOfRangeException: 索引 0 不是非负数且小于总行数。
源错误:
行 26: <ASP:LABEL id=Label4 107; LEFT: 280px; POSITION: absolute; TOP: 168px" Height="32px" Width="48px"
行 27: runat="server">项目号</ASP:LABEL>
行 28: <ASP:LABEL id=XM_NAME 106; LEFT: 368px; POSITION: absolute; TOP: 112px" Height="32px" Width="121px" runat="server" Text='<%# DataBinder.Eval(dataView1, "[0].XM_NAME", "{0}") %>'>
行 29: </ASP:LABEL>
行 30: <ASP:TEXTBOX id=TextBox1 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
{
///
/// WebForm1 的摘要说明。
///
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();
}
}
}
问题出在那里呀?
焦急万分、、