if (!IsPostBack)
   {

    string strConnection = null;
    string strSQL = null;
    strConnection = “Provider=Microsoft.Jet.OleDb.4.0;Data Source=”+Server.MapPath(“../database/database.mdb”);
    strSQL = “select ClassID,ClassName from [system_NewsClass] where ParentClassID=0″;

    OleDbConnection myOleDbConnection = new OleDbConnection(strConnection);
    OleDbDataAdapter myOleDbDataAdapter = new OleDbDataAdapter(strSQL,myOleDbConnection);
    DataSet myDataSet = new DataSet();
    myOleDbDataAdapter.Fill(myDataSet,”system_NewsClass”);
    ddlParentClassID.DataSource = myDataSet.Tables["system_NewsClass"];
    ddlParentClassID.DataValueField = myDataSet.Tables["system_NewsClass"].Columns["ClassID"].Caption;
    ddlParentClassID.DataTextField =  myDataSet.Tables["system_NewsClass"].Columns["ClassName"].Caption;
    ddlParentClassID.DataBind();
    ddlParentClassID.Items.Insert(0,new ListItem(“一级类别”,”0″));
    myOleDbConnection.Close();
   }


评论

该日志第一篇评论

发表评论

评论也有版权!