我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 网络学院 > 网络编程 > ASP专区 > Asp数据库/打印 > 关于DataView显示数据库详细信息的问题
热门文章排行
热门文章排行 ASP中access数据库的路径问题(03-23)
我是否可以将Excel数据导入?(03-23)
访问数据库(2)(03-23)
asp.net中读取数据库的两种方式(03-23)
VB/ASP数据库连接字符串示例(03-23)
精采文章排行
精采文章排行
技术专题推荐
网管论坛交流
 

关于DataView显示数据库详细信息的问题 

作者:佚名   来源:一亩三分地   点击:   日期:2007-03-23

点击链接后产生的问题如下:

索引 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();
   
  }
 }
}

问题出在那里呀?

焦急万分、、



文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·ASP中巧用Response属性 ·第六课:ASP脚本循环语句
·在 Web 页上使用条件数值格式 ·连接数据库查询手册(不仅仅适用于asp)
·警惕"给你的FileSystemObject对象加把锁" ·用ASP做全文检索

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。