Note that there are some explanatory texts on larger screens.

plurals
  1. POTo Display controls based on the dropdownlist selected item?
    primarykey
    data
    text
    <p>For Dropdownlist items i have written the following code:</p> <pre><code> protected void dropdowndatasrc() { con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); string command = "select eventname from Events"; cmd = new OleDbCommand(command); dataadapter = new OleDbDataAdapter(command, con); DataSet dataset = new DataSet(); con.Open(); DataTable dt = new DataTable("PayEvent"); dataadapter.Fill(dt); DropDownList4.DataSource = dt; DropDownList4.DataTextField = dt.Columns[0].ToString(); // DropDownList4.DataValueField = dt.Columns[0].ToString(); DropDownList4.DataBind(); } </code></pre> <p>I have to display controls based on the value of the dropdownlist (in the access database there is a column named payevent in that it has Yes/No datatype if the selected item in the database have 'yes' means display controls if not no controls must be displayed)</p> <p>I have tried this code but not worked</p> <pre><code>protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e) { TextBox11.Text = DropDownList4.SelectedItem.Text; con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); string query = "select payevent from Events where eventname=@dropdownlist"; con.Open(); //string query="select payevent from Events"; cmd = new OleDbCommand(query, con); cmd.Parameters.Add("@dropdownlist", selectedtext); OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string value = reader.GetValue((0)).ToString(); TextBox11.Text = value.ToString(); if (value == "True" || value == "true") { pnl.Visible = false; } else if (value == "False" || value == "false") { pnl.Visible = true; } } } </code></pre> <p><strong>the table structure as follows:</strong></p> <pre><code>**eventname payevent** Work Shop Yes emsisoft workshop Yes ECE No CSE No </code></pre> <p>Need help !!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload