If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > TextBox's not retrieving text properly?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-03, 14:29
GimpBoy GimpBoy is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
TextBox's not retrieving text properly?

Hi, I've recently gotten started putting together an ASP.NET C# Web Application using Visual Studio .NET.

I've run into a problem with modifying my database through a form with a whole bunch of TextBox's. I have another identical form where I add new database records to the database by having the user enter text into the fields and hitting the "add new" button - this works fine.

My problem is in my update form. I retrieve the database records and put them into the corresponding textBox's. The user can then modify these text-box's and click the "modify" Button. The problem is, these changes the user makes to the textBox's don't seem to be taken into account when I update the database - it just uses the same values that were in the textBox's before the user modified them.

Here's the page_load function:

Code:
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
sqlDataAdapter1.Fill(dataSet1);
DropDownList1.DataSource = dataSet1;
DropDownList1.DataTextField = "patient_LastName";
DropDownList1.DataValueField = "patient_ID";
DropDownList1.DataBind();
}

sqlSelectCommand2.Parameters["@DropDownListID"].Value = DropDownList1.SelectedItem.Value;
sqlDataAdapter2.Fill(dataSet2);		

txtFirstName.Text = (string) dataSet2.Tables["Patient"].Rows[0]["patient_FirstName"];
txtLastName.Text = (string) dataSet2.Tables["Patient"].Rows[0]["patient_LastName"];			
txtMiddleInitial.Text = (string) dataSet2.Tables["Patient"].Rows[0]["patient_MiddleInitial"];			
.....etc etc....
And here is the button click function:

Code:
private void Button1_Click(object sender, System.EventArgs e)
sqlSelectCommand4.Parameters["@patient_ID"].Value = DropDownList1.SelectedItem.Value;
sqlSelectCommand4.Parameters["@patient_FirstName"].Value = txtFirstName.Text;
sqlSelectCommand4.Parameters["@patient_LastName"].Value = txtLastName.Text;
..... etc etc .....
One thing I should mention - if I put txtFirstName.Text = "blah blah blah" at the top of that click button function, it inserts the "blah blah blah" string into the database. How do I get it to retrieve the text that the user types into the TextBox's?
Reply With Quote
  #2 (permalink)  
Old 09-30-03, 00:05
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
You might want to try the Microsoft.NET board here or this:
microsoft.public.dotnet.framework.aspnet
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
  #3 (permalink)  
Old 09-30-03, 15:02
GimpBoy GimpBoy is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
Cool

Ok, thanks.

BTW, that link doesn't seem to work.
Reply With Quote
  #4 (permalink)  
Old 09-30-03, 18:00
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
I know it's not really a link but rather a name of a newsgroup.

But here are a couple links for you:

SitePoint .NET Forum
http://www.sitepointforums.com/forum...00&forumid=141

ASP Messageboard - ASP.NET Forum
http://www.aspmessageboard.com/forum/aspplus.asp
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On