I have a asp:DropDownList control in a hidden popup, this popup is activated when the user clicks on an icon(image) on a row of a Gridview Control.
Then i use some jquery to select the row that's been clicked on and then i extract the values of the label controls on the gridview row and then want to populate the popup fields (Text box controls and the DropDown list controls default value), the idea being to use them to update the record in the row in the database.
The issue im having is populating the default selection in the dropdown control on the popup. I can populate the text boxes in the textboxes, just not the dropdown.
Here is the markup for one of the textboxes and the ddl from the gridview where i source my values:
<asp:TemplateField HeaderText="Current Stage">
<ItemTemplate>
<asp:Label ID="lblCurrentStage" CssClass="clCurrentStage" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CurrentStage")%>' ToolTip ='<%# DataBinder.Eval(Container.DataItem, "CurrentStage")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Review Date">
<ItemTemplate>
<asp:Label ID="lblReviewDate" CssClass="clReviewDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ReviewDate")%>' ToolTip ='<%# DataBinder.Eval(Container.DataItem, "ReviewDate")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
and here is the code that works fine on the textbox but not on the ddl:
<div id="PopUpTrackerEditFieldCurrentStage">
<div class="clEditFieldCurrentStageContainer">
<asp:DropDownList ID="ddlPopUpEditCurrentStage" runat="server"> </asp:DropDownList>
</div>
</div>
<div id="PopUpTrackerEditFieldReviewDate">
<div class="clEditFieldReviewDateContainer">
<asp:TextBox ID="tbPopUpEditReviewDate" CssClass="clPopUpDateFieldsInEdit" runat="server" Text="" ToolTip =""></asp:TextBox>
</div>
</div>
And here is jquery used to populate the textbox and dropdown list:
var row = $(this).closest("tr");
var strCurrentStage = $(".clCurrentStage", row).text();
$("#<%=ddlPopUpEditCurrentStage.ClientID%>").val(strCurrentStage);
$("#<%=ddlPopUpEditCurrentStage.ClientID%>").attr('title', 'Click to select the current stage here for ' + strPSTNNum);
var strReviewDate = $(".clReviewDate", row).text();
$("#<%=tbPopUpEditReviewDate.ClientID%>").val(strReviewDate);
$("#<%=tbPopUpEditReviewDate.ClientID%>").attr('title', 'Edit the review date here for ' + strPSTNNum);
I know strCurrentStage is ok because i temporaraly used it to populate the textbox to see if it contained the current stage text from the current stage label in the gridview and it did. So the issue i think is that i cannot select the correct part of the dropdown list control to populate the default value in.