pixelmeow
pixelmeow

Reputation: 654

Textbox not showing new text value from database update

I have textboxes that I load with data from the database when the page is first loaded and after a database update. Here is some of the code. From the vb code-behind:

Private Sub doLoad()
    Dim dvsqlClient As DataView
    dvsqlClient = CType(sqlClient.Select(DataSourceSelectArguments.Empty), DataView)
    toptxtCliName.Text = CType(dvsqlClient.Table.Rows(0)("ClientName"), String)
    txtCliName.Text = CType(dvsqlClient.Table.Rows(0)("ClientName"), String)
    '    load the rest of the textboxes
End Sub

After saving the input data, this code runs:

'    code that saves to database
'    show confirmation
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "generateSuccess", "generate('Client Saved.', 'success', 'center');", True)
'    load everything again
doLoad()

From the aspx page:

<asp:Table runat="server" BackColor="LightGray" Width="100%">
<asp:TableRow BackColor="LightGray">
    <asp:TableCell>
        <asp:TextBox ID="toptxtCliName" Enabled="false" CssClass="big_textbox textbox-disabled" runat="server"></asp:TextBox>
    </asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" TabStripPlacement="Top">
<ajaxToolkit:TabPanel runat="server" ID="ClientPanel" HeaderText="Client Info">
<ContentTemplate>
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<table>
<tr>
    <td class="right_column" colspan="5">
        <asp:TextBox ID="txtCliName" TabIndex="1" runat="server" CssClass="big_textbox"></asp:TextBox>
    </td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</asp:TableCell>
</asp:TableRow>
</asp:Table>

My datasource:

<asp:SqlDataSource ID="sqlClient" runat="server"
    ConnectionString='<%$ ConnectionStrings:xConnectionString %>'
    SelectCommand="SELECT ClientName
                     FROM view_Client
                    WHERE ClientCode = @ClientCode">
    <SelectParameters>
        <asp:QueryStringParameter QueryStringField="CLICODE" Name="ClientCode">
        </asp:QueryStringParameter>
    </SelectParameters>
</asp:SqlDataSource>

The first time through, and after refreshes, both text boxes show the same, correct, value. After running the save sub and running doLoad again. toptxtCliName.text still holds the previous value while txtCliName.text holds the new value. When I put a breakpoint on the boxes in the code-behind, the code shows that both textboxes are filled with the same text. But when the window comes back up, only txtCliName.text has the correct value. If I hit refresh, they both have the correct value when the page finishes loading.

As far as I can tell, it's the exact same code. Can anyone else see something I'm missing?

It's happening on two of my pages, same structure as this.

Upvotes: 0

Views: 1163

Answers (1)

user700390
user700390

Reputation: 2339

It's hard to say 100% without seeing all the code, but my guess is that you are hitting the server on an ajax callback and thus only the content within the UpdatePanel can be modified.

toptxtCliName needs to be inside an UpdatePanel based on what you are trying to accomplish. Try placing both controls within the UpdatePanel and see if that helps. Some other choices would be using two UpdatePanels, or possibly moving the UpdatePanel higher so that it starts immediately before the TableRow.

Upvotes: 1

Related Questions