我的数据库表qianfei 的id字段为自编,对欠费审核时,点击“处理/取消”显示索引超出范围,各位大神帮忙看看,感激不尽!!!
cs代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class 欠费审核 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.aa();
}
public void aa()
{
SqlConnection con = BD.createDB();
con.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter sda = new SqlDataAdapter("select * from qianfei ", con);
DataSet ds = new DataSet();
sda.Fill(ds, "qianfei");
this.gvqf.DataSource = ds;
this.gvqf.DataBind();
con.Close();
}
protected void gvqf_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
if (e.Row.Cells[7].Text == "已缴费")
{
e.Row.Cells[7].Text = "已缴费";
}
else
{
e.Row.Cells[7].Text = "未缴费";
}
}
}
protected void gvqf_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
_ string id = this.gvqf.DataKeys[e.NewSelectedIndex].Value.ToString();_
SqlConnection con = BD.createDB();
con.Open();
SqlCommand cmd = new SqlCommand("select state from qianfei where id='" + id + "'", con);
string count = cmd.ExecuteScalar().ToString();
if (count == "已缴费")
{
count = "未缴纳";
}
else
{
count = "已缴费";
}
cmd.CommandText = "update tousu set state='" + count + "'where id='" + id + "'";
cmd.ExecuteNonQuery();
con.Close();
this.aa();
}
protected void gvqf_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvqf.PageIndex = e.NewPageIndex;
this.aa();
}
}
我想上传调式图片,上传不了啊