Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

....Editing Page for a multi page Webform...

Status
Not open for further replies.

tridith

Programmer
Jul 22, 2005
39
CA
I am making a 4 paged webform where the user will be using textboxes, checkboxes, radio buttons, and dropdownboxes.

I have finished the part where the user is entering in a new "product", now I am trying to make it possible for the user to select a previously entered in product and edit it.

After the user selects the product they want to edit, the Oracle database is quiried according to the id of the product. Then what the database returns is put back into the form so the user can just edit what they want to edit., the following is an example of what i use to fill in some of the form. I am not sure if it is the best way to do it, but it works. :) ....If there is a better way to do this, please let me know.

getddlValue( ddlPointDescription, obReader.GetString(6) );
txtDateRecorded.Text = obReader.GetString(17);


private void getddlValue( DropDownList tempDDLBox, string stringFromSelect )
{
ListItem tempItem = null;
tempItem = tempDDLBox.Items.FindByText( stringFromSelect );
tempItem.Selected = true;
}


But here is where my problem arises.

Since my form is 4 pages long, and my boss doesn't want it to be one long page, I am using session variables to keep track of all the information in the forms. When the user click the submit button at the end of the form, this is what happens.

private void cmdSubmit_Click(object sender, System.EventArgs e)
{
addSessionVariables();
Response.Redirect("page_2.aspx");
}
private void addSessionVariables()
{
Session.Add("PointDesc", ddlPointDescription.SelectedItem.Text);
Session.Add("DateRec", txtDateRecorded.Text);
}


But when the Session.add is done on the textbox, it wont take the text that the user change it to, the text that it will take will always be what was taken from the database, I think it has to do with the source of the aspx page, when I look at the source it looks like this:
[blue]<input name="txtGPSTime" type="text" value="Some Time" id="txtGPSTime" />[/blue]
So I think what is happening is the session.add is grabbing the text from the "value" spot which is "Some Time" and not what the user may have changed the text to. Anyone know why it is doing this? Should I be grabbing the text a different way? What should I do??

For the drop down list box it is screwed up as well.
[blue]
<select name="ddlPointDescription" id="ddlPointDescription">
<option value=""></option>
<option value="Cabin">Cabin</option>
<option selected="selected" value="Camp">Camp</option>
<option value="Violation">Violation</option>
<option value="Park/Campground">Park/Campground</option>
<option value="Other">Other</option>
</select>[/blue]

Say the ddlbox looks like above and has 6 values in it. When the database was quiried, it returned the 3rd item in the ddlbox, so when the edit page is loaded, the 3rd item is automatically showen (Camp), but if the user changes the item to the 5th item (Park/Campground), then decides that they are done editing the form, go down to the bottom and press the submit button, that same code that is above is ran. The session.add will only grab the [red]"First"[/red] item that is selected, which will be Camp, it will not select the item that the user changed it to, unless the user selected, the blank option or Cabin ( the two items before Camp ).

I hope that I have explained my problem well and that there is someone out there that can help me solve it.
Thank you all for getting this far.

Chad
 
I resolved my own problem.

The reason it wasnt working was because I was missing this in my page_load

[blue]if(!Page.IsPostback)
{
//Logic to load product for Update from Database
} [/blue]

Thanks all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top