I am using MS VS 2010 and working on the ASP.NET C # website. I was stuck on something that, in my opinion, might be pretty simple, maybe not.
Suppose I have a drop-down list.
DropDownList ddl = new DropDownList(); ddl.ID = "d355"; dynamicPanel.Controls.Add(ddl); ListItem lstItem1 = new ListItem(); lstItem1.Text = "1"; ListItem lstItem2 = new ListItem(); lstItem2.Text = "2"; ddl.Items.Add(lstItem1); ddl.Items.Add(lstItem2); ddl.SelectedIndexChanged += new EventHandler(this.ddl_SelectedIndexChanged);
Since we programmatically created our drop-down list, we also need to create our custom event handler, to which we are attached.
protected void ddl_SelectedIndexChanged(object sender, EventArgs e) {
That is where my problem is. Read the comments in the event handler. (Sorry if my syntax is disabled, at the moment it's all free)
I have the feeling that I can get the previous selected index (or an element that doesn't matter) from the event arguments ((DropDownList) e).?
Please help>. <This does not seem too bad!
source share