我也是新手
建议看ms的quickstart
我觉得不错

解决方案 »

  1.   

    就你说的功能VB.NET和C#没什么大区别
      

  2.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    //System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\del_hbj\\db\\db1.mdb;Persist Security Info=False;Jet OLEDB:Database Password=111222";
    System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222";
    if(!this.IsPostBack)
    {
    OleDbConnection conn=new OleDbConnection(strcon);
    conn.Open();
    string strsql;
    if(TextBox1.Text=="")
    {
     strsql="select *from 支票数据";
     ListBox1.Visible=false;
    }
    else
    {
     strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'";
     ListBox1.Visible=true;
    } System.Data.DataSet ds=new DataSet();
    System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn);
    System.Data.DataTable dt=new DataTable();

    da.Fill(dt);
    da.Fill(ds,"支票数据");
        DataGrid1.DataSource=ds;
    DataGrid1.DataBind();
    ListBox1.DataSource=dt;
    ListBox1.DataTextField="用途";
    ListBox1.DataBind();
    DropDownList1.DataSource=ds;
    DropDownList1.DataTextField="收款人";
    DropDownList1.DataBind();
    if (ListBox1.Items.Count!=0)
    {
    Response.Write(ListBox1.Items[0].Value);

    }

    }
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.ListBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged_1);
    this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
    this.Repeater1.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.Repeater1_ItemCommand);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
    {

    } private void Button1_Click(object sender, System.EventArgs e)
    {
    System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222";

    OleDbConnection conn=new OleDbConnection(strcon);
    conn.Open();
       
    ListBox1.Visible=true;
    string strsql;
    if(TextBox1.Text=="")
    {
    strsql="select *from 支票数据";
    }
    else
    {
    strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'";
    ListBox1.Visible=true;
    } System.Data.DataSet ds=new DataSet();
    System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn);
    System.Data.DataTable dt=new DataTable();

    da.Fill(dt);
    da.Fill(ds,"支票数据");

    ListBox1.DataSource=dt;
    ListBox1.DataTextField="用途";
    ListBox1.DataBind();
    // TextBox1.Text=ListBox1.Items[2].Text;
    //TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text;
    }

    private void LinkButton1_Click(object sender, System.EventArgs e)
    {
    Response.Redirect ("Webchuanzhi.aspx?name="+TextBox1.Text);
    } private void ListBox1_SelectedIndexChanged_1(object sender, System.EventArgs e)
    {
    TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text;
    }