我用GridView 对某一项进行编辑时,数据库不能获取编辑后的值,是怎么回事,谁能帮帮我呢?
我用GridView 对某一项进行编辑时,数据库不能获取编辑后的值,是怎么回事,谁能帮帮我呢?
问一下下面代码里有没有错误啊!
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 backmanage_memberscoremanage : System.Web.UI.Page
{
SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings[ "conn "]);
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (Session[ "admin "] == null)
{
Server.Transfer( "backlogin.aspx ");
}
dsdatabind();
}
protected void dsdatabind()
{
strcon.Open();
string str = "SELECT id,username,score,address,tel from tb_users order by score desc ";
SqlDataAdapter datap = new SqlDataAdapter(str, strcon);
datap.Fill(ds);
GridView1.DataSource = ds;
this.GridView1.DataKeyNames = new string[] { "id " };
GridView1.DataBind();
strcon.Close();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
strcon.Open();
string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
SqlCommand comm = new SqlCommand( "delete from tb_users where id= " + id, strcon);
comm.ExecuteNonQuery();
strcon.Close();
dsdatabind();
}
protected void GridView1_RowEditing(