索引超出范围。必须为非负值并小于集合大小的问题 求高手解决 20
索引超出范围。必须为非负值并小于集合大小。参数名:index异常详细信息:System.ArgumentOutOfRangeException:索引超出范围。必须为非负值...
索引超出范围。必须为非负值并小于集合大小。
参数名: index
异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index
源错误:
行 46: protected void gvOrderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
行 47: {
行 48: string sqlstr = "delete from tb_OrderInfo where OrderID='" + gvOrderInfo.DataKeys[e.RowIndex].Value + "'";
行 49: sqloperate.DataCom(sqlstr);
行 50: Response.Redirect("OrderManage.aspx");
后台代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class AdminManage_OrderManage : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo";
//gvOrderInfo.DataKeyNames = new string[] { "OrderID" };
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
}
protected void btnSel_Click(object sender, EventArgs e)
{
if (txtKey.Text == "")
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
else
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo where "
+ ddlCondition.SelectedValue + " like '%" + txtKey.Text.Trim() + "%'";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
}
protected void gvOrderInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cells[2].Controls[0])).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
}
}
protected void gvOrderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlstr = "delete from tb_OrderInfo where OrderID='" + gvOrderInfo.DataKeys[e.RowIndex].Value + "'";
sqloperate.DataCom(sqlstr);
Response.Redirect("OrderManage.aspx");
}
protected void gvOrderInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvOrderInfo.PageIndex = e.NewPageIndex;
string sqlstr = "select distinct OrderMember from tb_OrderInfo where "
+ ddlCondition.SelectedValue + " like '%" + txtKey.Text.Trim() + "%'";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
protected void gvOrderInfo_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
怎么绑定 展开
参数名: index
异常详细信息: System.ArgumentOutOfRangeException: 索引超出范围。必须为非负值并小于集合大小。
参数名: index
源错误:
行 46: protected void gvOrderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
行 47: {
行 48: string sqlstr = "delete from tb_OrderInfo where OrderID='" + gvOrderInfo.DataKeys[e.RowIndex].Value + "'";
行 49: sqloperate.DataCom(sqlstr);
行 50: Response.Redirect("OrderManage.aspx");
后台代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class AdminManage_OrderManage : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo";
//gvOrderInfo.DataKeyNames = new string[] { "OrderID" };
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
}
protected void btnSel_Click(object sender, EventArgs e)
{
if (txtKey.Text == "")
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
else
{
string sqlstr = "select distinct OrderMember from tb_OrderInfo where "
+ ddlCondition.SelectedValue + " like '%" + txtKey.Text.Trim() + "%'";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
}
protected void gvOrderInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((LinkButton)(e.Row.Cells[2].Controls[0])).Attributes.Add("onclick", "return confirm('确定要删除吗?')");
}
}
protected void gvOrderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlstr = "delete from tb_OrderInfo where OrderID='" + gvOrderInfo.DataKeys[e.RowIndex].Value + "'";
sqloperate.DataCom(sqlstr);
Response.Redirect("OrderManage.aspx");
}
protected void gvOrderInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvOrderInfo.PageIndex = e.NewPageIndex;
string sqlstr = "select distinct OrderMember from tb_OrderInfo where "
+ ddlCondition.SelectedValue + " like '%" + txtKey.Text.Trim() + "%'";
sqloperate.gvDataBind(gvOrderInfo, sqlstr);
}
protected void gvOrderInfo_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
怎么绑定 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询