Help needed simple question...
Hello guys
I have made a simple web application.
It loads data from a database and then lets the user change the data and then save it by clicking the submit button.
see code below...
---------------------------------------------
Dim objCmd As New SqlCommand
objCmd.Connection = objConn
objConn.Open()
Dim strSQL As String = "saveDetails"
objCmd.CommandText = strSQL
objCmd.CommandType = CommandType.StoredProcedure
objCmd.Parameters.Add("@dr_id", id)
objCmd.Parameters.Add("@address", SqlDbType.NVarChar, 80).Value = addressBox.Text
objCmd.ExecuteNonQuery()
objConn.Close()
Response.Redirect("./doctors.aspx")
---------------------------------------------
address box is just a web forum textbox
For some reason addressBox.Text doesn't pick up the modified data.
The only way I can get the modifield data to be picked up is by using
request("addressBox")
does anyone know why this is??
any help is greatly appreciated.
Re: Help needed simple question...
Show the form's code (ASPX)
Re: Help needed simple question...
yea here it is...
------------------------------------------
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="editpage.aspx.vb" Inherits="BenefitsVB.editpage" EnableSessionState="True" enableViewState="False"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>editpage</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="addressBox" style="Z-INDEX: 101; LEFT: 112px; POSITION: absolute; TOP: 128px"
runat="server" Width="144px"></asp:TextBox>
<asp:Label id="city" style="Z-INDEX: 102; LEFT: 120px; POSITION: absolute; TOP: 176px" runat="server"
Width="144px" Height="24px">city</asp:Label>
<asp:Label id="state" style="Z-INDEX: 103; LEFT: 120px; POSITION: absolute; TOP: 224px" runat="server"
Width="152px" Height="24px">state</asp:Label>
<asp:Label id="phone" style="Z-INDEX: 104; LEFT: 24px; POSITION: absolute; TOP: 104px" runat="server"
Width="64px" Height="16px">phone</asp:Label>
<asp:Label id="address" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 136px" runat="server"
Width="64px" Height="24px">address</asp:Label>
<asp:Button id="save" style="Z-INDEX: 106; LEFT: 96px; POSITION: absolute; TOP: 288px" runat="server"
Width="96px" Height="32px" Text="save"></asp:Button>
<asp:TextBox id="phoneTextBox" style="Z-INDEX: 107; LEFT: 112px; POSITION: absolute; TOP: 96px"
runat="server" Width="152px"></asp:TextBox>
</form>
</body>
</HTML>
Re: Help needed simple question...
It should work.
Try this first:
Remove the address textbox from the ASPX code, then add it again. Then switch to the design view and save the page. Then go to your codebehind and add the code for addressbox.text.
If that doesn't work, try and see if the other web elements show up, like "city" or "state".
Re: Help needed simple question...
Also, place a breakpoint on that line and when you get to it, see if it says that addressbox is {Nothing}
Re: Help needed simple question...
when using the debugger the addressBox.text just shows its original value that was loaded from the database when the page_load sub was called.
its a strange one this...