Get selected value of dropdown from panel

A

Andy Sutorius

Hi,

I have 4 panels, each panel has a dropdown and a "next" button. I would like
to get the selected value of the dropdown after the next button is clicked.
I thought I could use the following (ddlChooseEmail.SelectedValue) to grab
the value but it does not work. Is there something special about panels that
I need to do in order to get the selected value of the dropdown?

Thanks,

Andy
 
G

Guest

Hi,

Eventhough you place some controls in Panels, you can directly refer from
your code behind with, their name. There should not be a problem.


I hope you to have a similar code as follows....

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TestApp
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.Panel Panel3;
protected System.Web.UI.WebControls.Panel Panel4;
protected System.Web.UI.WebControls.DropDownList ddl1;
protected System.Web.UI.WebControls.DropDownList ddl2;
protected System.Web.UI.WebControls.DropDownList ddl4;
protected System.Web.UI.WebControls.DropDownList ddl3;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.Button Button1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Button3.Click += new System.EventHandler(this.Button3_Click);
this.Button4.Click += new System.EventHandler(this.Button4_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(" - ");
Response.Write(ddl1.SelectedValue.ToString());
}

private void Button2_Click(object sender, System.EventArgs e)
{
Response.Write(" - ");
Response.Write(ddl2.SelectedValue.ToString());
}

private void Button3_Click(object sender, System.EventArgs e)
{
Response.Write(" - ");
Response.Write(ddl3.SelectedValue.ToString());
}

private void Button4_Click(object sender, System.EventArgs e)
{
Response.Write(" - ");
Response.Write(ddl4.SelectedValue.ToString());
}
}
}


Cheers,

Jerome. M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top