Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    5

    Unanswered: 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?

  2. #2
    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

  3. #3
    Join Date
    Sep 2003
    Posts
    5

    Cool

    Ok, thanks.

    BTW, that link doesn't seem to work.

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •