Databound Countrols Inside UpdatePanel Not Saving To Database

Currently working with the EditItemTemplate section of a FormView Control.  Using AJAX to auto-populate State and County based on ZIP Code entered.  The AJAX functionality works fine, but when I click save nothing (or empty strings) gets saved to the dabase.  When I pull up the form again all fields inside the updatepanesl are blank. This form was working/saving fine before I introduced the AJAX...
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td style="padding-top:6px" width="50%">
            <a class="TextLabel">State/Zip</a><br />
            <asp:UpdatePanel id="UpdatePanel1" runat="server">
                <contenttemplate>
            <asp:SqlDataSource ID="sqlState" runat="server" ConnectionString="<%$ConnectionStrings:NICASConnectionString %>"
                SelectCommand="SELECT DISTINCT state FROM Locale ORDER BY state">
            </asp:SqlDataSource>
            <asp:DropDownList ID="cboState" runat="server" CssClass="TextBox" DataSourceID="sqlstate" DataValueField="state" DataTextField="state" selectedvalue='<%# Bind("state") %>' AppendDataBoundItems="true" AutoPostBack="false" OnSelectedIndexChanged="ClearCounty">
                <asp:ListItem value="" Text=""></asp:ListItem>
            </asp:DropDownList>
            <asp:TextBox ID="txtZip" runat="server" CssClass="TextBox" Width="60px" MaxLength="10" Text='<%# Bind("zip") %>' AutoPostBack="true" OnTextChanged="txtZip_TextChanged"></asp:TextBox>
            </contenttemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="txtZip" EventName="TextChanged" />
                </Triggers>
            </asp:UpdatePanel>
        </td>
        <td style="vertical-align:top"; width="50%">
            <a class="TextLabel">County</a>&nbsp;
            <br />
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
            <asp:SqlDataSource ID="sqlCounty" runat="server" ConnectionString="<%$ ConnectionStrings:NICASConnectionString %>" 
                SelectCommand="SELECT county FROM Locale WHERE state=@state ORDER BY county">
                <SelectParameters>
                    <asp:ControlParameter ControlID="fvLoc$cboState" PropertyName="SelectedValue" Name="state" Type="string" />
                </SelectParameters>     
            </asp:SqlDataSource>
            <asp:DropDownList ID="cboCounty" runat="server" CssClass="TextBox" AutoPostBack="True" DataSourceID="sqlCounty" DataTextField="county" DataValueField="county" AppendDataBoundItems="true" OnSelectedIndexChanged="SetWorkunit">
                <asp:ListItem Value="" Text=""></asp:ListItem>
            </asp:DropDownList>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="txtZip" EventName="TextChanged" />
                </Triggers>
            </asp:UpdatePanel>
        </td>
    </tr>
</table>

Open in new window

synapse88Asked:
Who is Participating?
 
synapse88Connect With a Mentor Author Commented:
I figured it out.  Just have to use something like e.NewValues.Item("state") = CType(fvLoc.FindControl("cboState"), DropDownList).SelectedValue in the itemupdating event.
0
 
cciservicesCommented:
This one can be tricky, but sometimes I have been required to put the: UpdateMode="Conditional" in the Update Panel.  Just a thought....
0
 
cciservicesCommented:
Ah, good one.  That actually helps me out as well.
0
All Courses

From novice to tech pro — start learning today.