点更新,还是以前的数据没变,我用Result.Text(是一个 Label)显示了一下。结果数据没有更新
解决方案 »
- 杯具啊~ 哪位仁兄给出出主意~
- gridview里面的checkbox定义一个OnCheckedChanged为何没有用
- c#chart图像更新问题
- Gridview DropDownList 根据读出来数据选中选项的情况
- 一个权限问题,和sql 问题 希望大哥们回答
- Log4net 怎么试都不行,help me
- 嵌套的hashtable动态生成table?急急急!!!
- <mobile:Label得到的文本可否换行呢?我怎么找不到换行符号呢?
- asp.net下使用mysql的问题
- asp.net 问题
- 网站在域名子目录下如何访问
- 上传图片到 photo文件夹,在本机运行正常,但上传到服务器以后出现错误
if (!Page.IsPostBack)
startIndex = 0;
BindGrid(); 改成
if (!Page.IsPostBack)
{
Conn = new SqlConnection("server=localhost;database=StudentBook;uid=sa;pwd='ibm'");
startIndex = 0;
BindGrid();
}
试试
{
if (!Page.IsPostBack)
{
band();
}
}
private void band()
{
string connString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection con = new SqlConnection(connString);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("select * from Capital order by newid()", con);
DataSet ds = new DataSet();
sda.Fill(ds);
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
con.Close();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
this.GridView1.EditIndex = e.NewEditIndex;
band();
} protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.GridView1.EditIndex = -1;
band();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{ string connString=ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection con = new SqlConnection(connString);
con.Open();
string aa = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
string bb = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString();
string cc = "update Capital set capitalcode='" + bb + "' where DomainID='" + aa + "'";
SqlCommand cmd = new SqlCommand(cc, con);
cmd.ExecuteNonQuery();
con.Close();
this.GridView1.EditIndex = -1;
band();
//Response.Write("<script>alert('更新成功!')</script>");
}
startIndex = 0;
BindGrid();
================= if (!Page.IsPostBack)
{
startIndex = 0;
BindGrid();
}