Click here to Skip to main content
13,091,537 members (71,437 online)
Rate this:
Please Sign up or sign in to vote.
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 12-Feb-13 23:37pm
Updated 13-Feb-13 8:38am
CShubham 13-Feb-13 6:16am
Remove ispostback from your code and try
Karthik Harve 13-Feb-13 7:01am
Still confusion is that, which dropdownlist not firing event, drpFrom, drpTo or drpUniversity ?
bandi.ramesh 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
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