当前位置: 代码迷 >> ASP.NET >> 关于DataGrid的有关问题
  详细解决方案

关于DataGrid的有关问题

热度:8621   发布时间:2013-02-26 00:00:00.0
关于DataGrid的问题!
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.OleDb;

public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {

        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                OleDbConnection   Conn   =   new   OleDbConnection();
                Conn.ConnectionString   = "Provider=Microsoft.Jet.OLEDB.4.0; "+
                        "Data   Source= "+Server.MapPath( "access.mdb ");
                Conn.Open();
                string   sql   =   "select   *   from   employs_Infos ";
                if   (TextBox1.Text   !=   " ")
                        sql   =   "Selecte   *   from   employs_Infos   Where   name   like '% "   +   TextBox1.Text   +   "% ' ";
                OleDbCommand   Comm   =   new   OleDbCommand(sql,   Conn);
                OleDbDataReader   DR   =   Comm.ExecuteReader();
            DG.DataSource   =   DR;
              DG.DataBind();
                Conn.Close();
        }
}
大家帮我看看哪错了     怎么.net提示说   “用户代码为处理”
还有我的.net中没有DataGrid控件!
我就把代码直接写上了
  <asp:DataGrid   ID= "DG "   runat= "server ">
  </asp:DataGrid> &nbsp;
帮我看看哪处错了阿!
谢谢回复!!!

------解决方案--------------------------------------------------------
sql = "Selecte * from employs_Infos Where name like '% " + TextBox1.Text + "% ' ";
是不是也该改成下面的呀。
sql = "Selecte * from employs_Infos Where name like '% " + TextBox1.Text + "% ' ";

  相关解决方案