Click here to Skip to main content
11,435,319 members (50,326 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#2.0 C# ASP.NET C#4.0
I have two DropDownList in my page and AutoPostBack property is true. But when I am clicking any DropDownList and changing it's index it;s working good. Then when I am clicking another DropDownList than its not working. Can you tell me how it will work every time after PostBack?

protected void drpFrom_SelectedIndexChanged(object sender, EventArgs e)
            if (IsPostBack)
                int year = Convert.ToInt16(drpFrom.SelectedItem.Value.ToString());
                for (int i = 0; i < 2; i++)
                    drpTo.Items.Insert(i, (year + 1).ToString());
                    year += 1;
 protected void drpUniversity_SelectedIndexChanged(object sender, EventArgs e)
            if (IsPostBack)
                if (drpUniversity.SelectedItem.Value.ToString() == "Others".ToString())
                    int rowcount = mytable.Rows.Count;
                    HtmlTableRow row = new HtmlTableRow();
                    row.ID = "tbl_row" + (rowcount + 1);
                    HtmlTableCell cell1 = new HtmlTableCell();
                    cell1.ID = "tbl_cell1" + (rowcount + 1);
                    HtmlTableCell cell2 = new HtmlTableCell();
                    cell2.ID = "tbl_cell2" + (rowcount + 1);
                    cell1.Attributes["class"] = "contact";
                    cell2.Attributes["class"] = "contact";
                    TextBox tb = new TextBox();
                    tb.ID = "tbQty" + (rowcount + 1);
                    tb.Width = 276;
                    Label lblotherUniver = new Label();
                    lblotherUniver.ID = "lbluniversity";
                    lblotherUniver.Text = "University Name";
                    mytable.Rows.Insert(8, row);
In the second dropdownlist I have add a new TextBox. How can I get value from this textbox too?
Posted 13-Feb-13 0:37am
Edited 13-Feb-13 9:38am
(no name)34.1K
CShubham at 13-Feb-13 6:16am
Remove ispostback from your code and try
Karthik Harve at 13-Feb-13 7:01am
Still confusion is that, which dropdownlist not firing event, drpFrom, drpTo or drpUniversity ?
bandi.ramesh at 13-Feb-13 22:09pm
better your post your complete code so that we can understand

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web03 | 2.8.150428.2 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100