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>");
        }
    }
}请问我应该怎么改,改在那里,谢谢

解决方案 »

  1.   

    没有这个方法
    bind(); 写个吧
      

  2.   

    bind()是什么?
    这个方法呢?
      

  3.   

    page类哪来的这个方法。
    楼主是想把数据绑定到控件吧。那也只有DataBind方法。拷贝别人代码也拷齐全啊……
      

  4.   

    应该是 
    protected void Page_Load(object sender, EventArgs e) 

        if (!IsPostBack) 
        { 
                GridView1.DataBind(); 
        } 

    吧!要不就是自己写了个绑定GridView1的方法bind(),然后在需要的地方调用!
      

  5.   

    楼主  我也遇到你这个问题,后来我在书上又多翻了两页看看有没有关于bing()的定义,结果被我找到了,你也看看??