__doPostBack() is not fired when having dropdown selectedindex is same

acidmc

New Member
I have two dropdown ddlCountry and ddlState and one button Submit.
While ddlstate is in update panel.
On submit of button value of both dropdown store in database.
And I show the data in Repeater Control.(In HTML Table structure)ASPX CODE\[code\]<table id="tablelist" class="csstablelist" cellspacing="1" cellpadding="1"> <tr> <td class="csstablelisttoptr"> ddlCountryID </td> <td class="csstablelisttoptr"> ddlCountryText </td> <td class="csstablelisttoptr"> ddlstateText </td> </tr> <asp:Repeater ID="repeaterList" runat="server" OnItemDataBound="repeaterList_ItemDataBound"> <ItemTemplate> <tr onclick="selectRow(this);"> <td class="csstablelisttd" style="display: none"> <asp:Label ID="ddlCountryID" runat="server" Text='<%#Eval("ddlCountryID")%>'></asp:Label> </td> <td class="csstablelisttd"> <asp:Label ID="ddlCountryText" runat="server" Text='<%#Eval("ddlCountryText")%>'></asp:Label> </td> <td class="csstablelisttd"> <asp:Label ID="ddlstateText" runat="server" Text='<%#Eval("ddlstateText")%>'></asp:Label> </td> </tr> </ItemTemplate> </asp:Repeater> </table><asp:DropDownList ID="ddlCountry" runat="server" CssClass="csstextbox" Width="207px" AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"></asp:DropDownList><asp:UpdatePanel ID="updatePanelState" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlState " runat="server" CssClass="csstextbox" Width="177px"> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlCountry" EventName="SelectedIndexChanged" /> </Triggers></asp:UpdatePanel><asp:Button ID="btnSave" runat="server" Width="80px" OnClientClick="return validateForm();" Text="Save" CssClass="cssbutton" OnClick="btnSave_Click" />ddlCountryID | ddlCountryText | ddlstateText1 | USA | XYZ2 |India | PQR\[/code\]Onclick of TR i write below (SelectRow(this)) function in javascript for highliting the repeater value and dropdown value match and getting selected.\[code\]<script type="text/javascript">function selectRow(objTR){ var ddlCountry =document.getElementById('<%=ddlCountry.ClientID %>'); var ddlState =document.getElementById('<%=ddlState .ClientID %>'); for (i = 0; i < ddlCountry .options.length; i++) { if (ddlCountry .options.text == objTR.cells[1].innerText.trim()) break; } ddlCountry .options.selected = true; __doPostBack(ddlCountry .id, objTR.cells[2].innerText.trim()); }</script>\[/code\]I write ddlCountry SelectedIndexChangedEvent In code behind.From Javascript I am firing __doPostBack() and passing ddlCountry as event target ddlStateText as event argument to SelectedIndexChangedEvent and getting value in event like this.\[code\]string stateDescription = Request["__EVENTARGUMENT"];ddlState .Items.FindByText(stateDescription ).Selected = true;//for highliting the repeater value and dropdown value match and selected\[/code\]Binding Country on pageLoad\[code\] if(!Ispostback)protected Void BindCountry(){strSQL = @"SELECT countryID,Country from Country_Master"; DataTable dataTableCountry = null; dataTableCountry = objSqlDbComm.ExecuteDatasetQuery(strSQL).Tables[0]; int countryID; string Country; var dictioneryCountry = new Dictionary<int, string>(); foreach(DataRow dr in dataTableCountry.Rows) { countryID = Convert.ToInt32(dr["countryID"]); Country= dr["Country"].ToString(); dictioneryCountry.Add(countryID,Country); } ddlCountry.Items.Clear(); ddlCountry.DataTextField = "Value"; ddlCountry.DataValueField = "Key"; ddlCountry.DataSource = dictioneryCountry; ddlCountry.DataBind(); ddlCountry.Items.Insert(0, new ListItem("[Select]", "-1")); ddlCountry.Items[0].Selected = true;}\[/code\]My problem is if I have following repeater data.\[code\]ddlCountryID | ddlCountryText | ddlstateText1 | USA | XYZ2 |India | PQR2 |India | MNO\[/code\]When I select row number 3 that have country india and state mno then __dopostback() method is fire.When I goes to row number 1 then __dopostback() method is fire.When I come from row nuber 1 to 3 then method is fire correct way but when goes from row nuber 3 to 2 having country id same __dopostback() method is not fire and state is not selected from ddlstate.
 
Top