void Page_Load(object sender, EventArgs e) { if (!(Page.IsPostBack)) { gridv.DataSource = LoadMyPBData(); gridv.DataBind(); } }-------------------------------String StrSql="Data Source=127.0.0.1;Initial Catalog=dotnet;persist security info=True;user id=sa;password=1234;packet size=4096";SqlConnection MyConn = new SqlConnection(StrSql);MyConn.Open();string CommSql = "select * from gbook order by id desc";SqlDataAdapter adp = new SqlDataAdapter(CommSql,MyConn);DataSet ds = new DataSet();adp.Fill(ds);DataGrid1.DataSource = ds;DataGrid1.DataBind();MyConn.Close();--------------------------------------- if(!IsPostBack) { OleDbConnection MyConnection =new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("new.mdb")); OleDbDataAdapter myCommand=new OleDbDataAdapter("SELECT id,typename FROM bb ",MyConnection); DataSet ds= new DataSet(); myCommand.Fill(ds,"bb"); DropDownList2.DataSource = ds.Tables["bb"].DefaultView; DropDownList2.DataTextField = "typename"; DropDownList2.DataValueField = "id"; DropDownList2.DataBind();
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18