Fails to save updates.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
I am trying to add in a new section using other parts as a guide.

it all seems to work fine as far as getting the values from SQL, displaying them on the page and so on but when I go to save changes it will not pull the new text info I entered in to the page. for example:

DistributorInfo.ascx

<tr>
        <td class="adminTitle">
            <nopCommerce:ToolTipLabel runat="server" ID="lblParentIdTitle" Text="Parent ID" ToolTip="ParentId"
                ToolTipImage="~/Administration/Common/ico-help.gif" />
        </td>
        <td class="adminData">
            <asp:TextBox ID="txtParentId" runat="server" CssClass="adminInput"></asp:TextBox>
        </td>
    </tr>

in the code behind I have,

public Distributor SaveInfo()
        {
            Distributor distributor = DistributorManager.GetDistributorById(this.DistributorId);
                        
            string name = txtName.Text.Trim();
            int parentId = int.Parse(txtParentId.Text.Trim());

in the txt box I will enter "1" with the old value being "9"
when I step through the code int parentId = int.Parse(txtParentId.Text.Trim()); it grabes the old value of 9 and not the 1 that was just entered. if I change it to parentId = 1; then it updates the database with no problems.

Any idea on what could cause this?
13 年 前
Well at least I'm learning,

turns out that the add function worked and the update did not because of two simple lines of code and a mistake I've made many times and still keep making.


private void BindData()
        {
            Distributor distributor = DistributorManager.GetDistributorById(this.DistributorId);
            if (distributor != null)
            {
                this.txtName.Text = distributor.DistributorName;
                this.txtParentId.Value = distributor.ParentId;
                this.txtFLimit.Text = distributor.FLimit.ToString();
                this.txtFCount.Text = distributor.FCount.ToString();
                this.txtDistributorCredit.Text = string.Format("{0:c}", distributor.DistributorCredit.ToString());
                this.cbActive.Checked = distributor.Active;
                this.cbBlocked.Checked = distributor.Blocked;
                this.txtAdminComment.Text = distributor.AdminNote;
                this.txtPeachTreeId.Text = distributor.PeachTreeId;
            }
        }


and the most important part


protected void Page_Load(object sender, EventArgs e)
        {
                this.BindData();
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.