Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MmTextBox reverts back to zero
Message
From
25/02/2008 19:04:41
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01296241
Message ID:
01296283
Views:
9
Hi Bob,

>
>I have an mmTextBox placed on a web form and have bound it to a business object column using the bindingsource and bindingsourcemember properties. I also have a button next to this control with the following event code:
>
>
>// Create a new trader profit record
>        TraderprofitDefaults TPD = new TraderprofitDefaults(this.profitID, Convert.ToInt32(this.cboTrader.SelectedValue));
>        this.oTraderProfit.NewEntity(TPD);
>        if (mmSaveDataResult.RulesPassed == this.oTraderProfit.SaveEntity())
>        {
>            string nextScreen = "ProfitEditForm.aspx?profitID=" + this.profitID.ToString();
>            mmMessageDisplay.DisplayMessage("System Confirmation", "Trader Allocation Record Successfully Saved",
>                nextScreen, 3);
>        }
>
>
>The code is to add a new row into the trader profit table. This table has three columns. The two referenced above as default values and the third the value in the mmTextBox that is entered by the user (before the button is clicked to add the row).
>
>My problem is that the value entered in the text box is lost each time I click the button as it reverts back to zero. Can anyone help me to explain what is happening here?
>
>Thanks in advance.

If the user is entering this value you don't want reset then you need to store it in a session for instance and reset it in the page_load on postback.

for instance in the button click event:
Session["myTextboxValue"] = mmTextBox1.Text;

Then in the page load test for if a postback or not and reset the value the user had,
if (IsPostBack)
mmTextBox1.Text = (string)Session["myTextboxValue"];

I hope that helps
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform