tags:

views:

20

answers:

1

I have an asp web form which is used for database entry located at

localhost/EnterNewData.aspx

I also want to use this form to view entries in the database by passing the database id

localhost/EnterNewData.aspx?id=12

This all works fine. What I want to do now is if I am viewing an entry and one of the fields is incorrect, I can change it in the form and click the submit button and update the entry. The code checks if an id has been passed and if it has then it does an SQL update instead of an insert, however, none of the data seems to be getting updated. It's not a database issue as I have stepped through the code and have found the error here:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string name = HttpUtility.HtmlEncode(txtBxName.Text);

The value txtBxName.Text still holds the original text that was in the web form field when the page was loaded, not the new text that I have typed in there before pressing the submit button.

Any ideas would be extremely helpful.

Thanks

G

+2  A: 

Can we see your Page_Load event? It might be a case of specifying the following IF statement when pre-populating the values:

if (!Page.IsPostBack) {
    //Pre-fill textboxes here
}
Curt
A thousand up votes and my humble thanks to you sir!
Gavimoss
No problem :) glad to help!
Curt