using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
string sqlstr = "Data Source=192.168.0.98;Database=lbs_Test;Uid=sa;Pwd=1";
SqlConnection sqlconn;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bind();
}
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
try
{
string str = "delete from Region where data='" + GridView1.DataKeys[e.AffectedRows].Value + "'";
sqlconn = new SqlConnection(sqlstr);
sqlconn.Open();
SqlCommand sqlcom = new SqlCommand(str, sqlconn);
sqlcom.ExecuteNonQuery();
sqlconn.Close();
//this.bind();
}
catch
{
Response.Write("<script>alert('不能删除系统表中自带的字段')</script>");
}
}
}请问我应该怎么改,改在那里,谢谢
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page
{
string sqlstr = "Data Source=192.168.0.98;Database=lbs_Test;Uid=sa;Pwd=1";
SqlConnection sqlconn;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.bind();
}
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
try
{
string str = "delete from Region where data='" + GridView1.DataKeys[e.AffectedRows].Value + "'";
sqlconn = new SqlConnection(sqlstr);
sqlconn.Open();
SqlCommand sqlcom = new SqlCommand(str, sqlconn);
sqlcom.ExecuteNonQuery();
sqlconn.Close();
//this.bind();
}
catch
{
Response.Write("<script>alert('不能删除系统表中自带的字段')</script>");
}
}
}请问我应该怎么改,改在那里,谢谢
解决方案 »
- 请问,MouseClick事件怎么不起作用
- 控制台应用程序下判断用户是否通过键盘输入内容
- 怎么用Graphics去填充一个环形封闭图形?
- 字符串转换成汉字问题
- c# windows services 与程序端交互,觉得有难度
- 问一个弱智问题:怎么看一个打印机能否支持A2大小的纸张?
- web服务程序和服务器内存耗用的问题,请指点
- TabControl控件中的图片消失了?是什么原因?
- c#里怎样在程序里调用javascript里的程序,打开页面
- 新手刚来,想求一个免费的或者便宜的(100块以下)通用验证码识别控件。。
- c#如何实际一个方法的间隔循环执行?
- 在知道DataTable某一列数据的情况下,如何得到这个数据的行索引?
bind(); 写个吧
这个方法呢?
楼主是想把数据绑定到控件吧。那也只有DataBind方法。拷贝别人代码也拷齐全啊……
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataBind();
}
}
吧!要不就是自己写了个绑定GridView1的方法bind(),然后在需要的地方调用!