Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to dynamic bind Listbox DataSource?

How to dynamic bind Listbox DataSource?

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Old Gun
    wrote on last edited by
    #1

    I want to change my ListBox DataSource by a button event,but Where page reload ,The listbox is empty,How to do?

    J W 2 Replies Last reply
    0
    • O Old Gun

      I want to change my ListBox DataSource by a button event,but Where page reload ,The listbox is empty,How to do?

      J Offline
      J Offline
      just3ala2
      wrote on last edited by
      #2

      Can u explain more?

      Best Regards 3ala2 :)

      1 Reply Last reply
      0
      • O Old Gun

        I want to change my ListBox DataSource by a button event,but Where page reload ,The listbox is empty,How to do?

        W Offline
        W Offline
        Waseem_Kanafani
        wrote on last edited by
        #3

        you should change property "AutoPostBack=Ture" in the listbox properties. try it i think it helpful.

        O 1 Reply Last reply
        0
        • W Waseem_Kanafani

          you should change property "AutoPostBack=Ture" in the listbox properties. try it i think it helpful.

          O Offline
          O Offline
          Old Gun
          wrote on last edited by
          #4

          I test your tips, it still does not work,my code is here. using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using WinPbMove; namespace WebPbMove { /// /// public class WebProdSelect : MetaBuilders.WebControls.DialogPage { protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.ListBox ListBox1; protected System.Web.UI.WebControls.Button cmdFilter; protected System.Web.UI.WebControls.Button cmdReturn; private PbMove dl = null; const string MYSTRING = "-------"; private void Page_Load(object sender, System.EventArgs e) { string strSQL = ""; if (!Page.IsPostBack) { if (dl == null) dl = new PbMove(); if (dl.OpenConnection() == false) throw(new SystemException("Connect Oracle Failed!")); OleDbConnection cn = dl.Connection; if (TextBox1.Text == "") { strSQL = "Select t.prdct_name || '" + MYSTRING + "' || t.dscr From ip_prdct t"; } else { //TextBox1.Text = Session["UserFilterString"].ToString(); strSQL = "Select t.prdct_name || '" + MYSTRING + "' || t.dscr From ip_prdct t" + " Where t.dscr like '%" + TextBox1.Text + "%'"; } OleDbDataAdapter adpter = new OleDbDataAdapter(strSQL,cn); DataSet ds = new DataSet(); adpter.Fill(ds,"IP_PRDCT"); DataTable dtProdct = ds.Tables["IP_PRDCT"]; ListBox1.DataSource = dtProdct; ListBox1.DataTextField = dtProdct.Columns[0].ColumnName; ListBox1.DataValueField = dtProdct.Columns[0].ColumnName; ListBox1.DataBind(); } } #region Web override protected void OnInit(EventArgs e) { // // InitializeComponent(); base.OnInit(e); } /// /// private void InitializeComponent() { this.cmdFilter.Click += new System.EventHandler(this.cmdFilter_Click); this.cmdReturn.Click += new System.EventHandler(this.cmdReturn_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void cmdFilter_Click(object sender, System.EventArgs e) { if (dl == null) dl = new PbMove(); if (dl.OpenConnection() == false) throw(new SystemException("Connect Oracle F

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups