Dropdown list

Results 1 to 3 of 3

Thread: Dropdown list

  1. #1
    Join Date
    Dec 1969

    Default Dropdown list

    Hi,<BR> I have dropdown list, which is bound to one of the fields in my database and a labelbox. I want to change the message lable&#039;s value every time the user selects a different value on the dropdown list. So, I set AUTO POSTBACK ="TRUE" and in the DropDownList1_SelectedIndexChanged event I have<BR><BR> Label1.Text= DropDownList1.SelectedItem.Value<BR><BR> The data binds to the dropdown list just fine. But the label&#039;s text is not changed when I choose a different value on the drop down list.<BR><BR> Here&#039;s the code that binds data to to dropdown list when I click a button:<BR><BR> private void Button1_Click(object sender, System.EventArgs e)<BR><BR> {<BR><BR> OleDbDataReader objRdr;<BR><BR> OleDbConnection objConn;<BR><BR> OleDbCommand objCmd;<BR><BR> //DECLARE A CONNECTION///<BR><BR> objConn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; " +<BR><BR> "Data Source=C:\Inetpub\wwwroot\HannaDotNet\db\Techbooks .mdb");<BR><BR> //CREATE A COMMAND //<BR><BR> objCmd= new OleDbCommand("Select * from Books",objConn);<BR><BR> //Open CONNECTION<BR><BR> objConn.Open();<BR><BR> //Create & Execute Reader<BR><BR> objRdr = objCmd.ExecuteReader(CommandBehavior.CloseConnecti on);<BR><BR> DropDownList1.DataSource= objRdr;<BR><BR> DropDownList1.DataValueField= "Seller_Id";<BR><BR> DropDownList1.DataTextField = "Title";<BR><BR> DropDownList1.DataBind();<BR><BR> objRdr.Close();<BR><BR> objConn.Close();<BR><BR> }<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default How are you assigning a value in Page_Load?

    If you&#039;re changing the value of the label on page load and you&#039;ve forgotten the page postback that could be it...<BR><BR>Tim

  3. #3
    Join Date
    Dec 1969

    Default RE: How are you assigning a value in Page_Load?

    trying setting AutoPostBack = true on the dropdownlist box

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts