关于取值的问题

开发一个NBear作为基础框架的网站的时候,遇到了一个很变态的问题,自己苦思加从网上都没有找到相关的解法,只好发帖到首页来求解,真的很急的一个东西,希望大家体谅。

这个主要问题就是我有一个更新的页面产品的页面,在界面加载的时候用下面的代码初始化的页面上面控件的值:

protected void Page_Load(object sender, EventArgs e)
{
    SureLogin();
    int id = GetIntParam("id", 0);
    if (id == 0)
    {
        Response.Redirect("managegoods.aspx");
    }
    else
    {
        dsCategory.Filter(WhereClip.All);
        ddlCategory.DataBind();
        Goods aGoods =
            Gateways.SdaiBuy.Find<Goods>(id);
        ddlCategory.SelectedValue = aGoods.GoodsCategory.ID.ToString();
        tbMarketing.Text = aGoods.Marketing.ToString ();
        tbName.Text = aGoods.Name;
        tbPrice.Text = aGoods.Price;
        tbStock.Text = aGoods.Stock.ToString();
        weIntro.Text = aGoods.Content;
    }

}

然后在我更新按钮里面写了下面的代码更新数据库:

protected void btnSubmit_Click(object sender, EventArgs e)
{
    //上传图片
    bool fileOK = false;
    string path = Server.MapPath("~/UpFile/");
    string picname = string.Empty;
    if (FileUploadPic.HasFile)
    {
        string fileExtension = System.IO.Path.GetExtension(FileUploadPic.FileName).ToLower();
        string[] allowExtensions ={ ".gif", ".png", ".jpeg", ".jpg", ".bmp" };
        for (int i = 0; i < allowExtensions.Length; i++)
        {
            if (fileExtension == allowExtensions[i])
            {
                fileOK = true;
            }
        }
    }
    if (fileOK)
    {
        try
        {
            FileUploadPic.SaveAs(path + FileUploadPic.FileName);
            picname = System.IO.Path.GetFileName(FileUploadPic.PostedFile.FileName);
        }
        catch (Exception ex)
        {
            Label1.Text = "失败";
        }
    }

    //将商品记录更改加入数据库
    int id = GetIntParam("id", 0);
    Goods aGoods =
           Gateways.SdaiBuy.Find<Goods>(id);
    aGoods.Marketing = Convert.ToInt32 ( tbMarketing.Text);
    aGoods.Name = tbName.Text;
    if (picname != string.Empty)
    {
        aGoods.PicPath = "upfile/" + picname;
    }
    aGoods.Price = Server.HtmlEncode ( tbPrice.Text.Trim ());
    aGoods.Stock = Convert.ToInt32 (tbStock.Text);
    aGoods.Content = weIntro.Text;

    Gateways.SdaiBuy.Save<Goods>(aGoods);
    Category aCategory = Gateways.SdaiBuy.Find<Category>(Convert.ToInt32 (ddlCategory.SelectedValue) );
    aCategory.ShopGoods.Add(aGoods);

    Gateways.SdaiBuy.Save<Category>(aCategory);
    Response.Redirect("manageGoods.aspx");
}

发现了一个问题,就是所有控件的值只能取到我在页面初始化时给他加载的值,而取不到我在里面输入的最新的值,怀疑是不是微软的东西有错误,大家有没有遇到这个问题的给我说说,谢谢了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值