在窗口中新增一条数据,保存成功后重新绑定表格出现错误,请高手解答
protected void btnNew_Click(object sender, EventArgs e)
{
InwardDetail entity1 = new InwardDetail();
entity1 = BllInwardDetail.SelectModel(Convert.ToInt32(hidId.Text));
InwardTallyDetail entity = new InwardTallyDetail();
entity.InwardId = entity1.InwardId;
entity.SkuId = entity1.SkuId;
entity.InwaDId = int.Parse(hidId.Text);
entity.LocationId = ddlLoc.SelectedItem.Value;
entity.BatchNo = txtBatch.Text;
entity.LabelNo = txtLabel.Text;
entity.Memo1 = txtMemo1.Text;
entity.Memo2 = txtMemo2.Text;
entity.TallyQty = Convert.ToDecimal(txtQty.Text);
entity.TallyPcs = Convert.ToDecimal(txtPcs.Text);
entity.PurPrice = Convert.ToDecimal(lblPrice.Text);
BllInwardTallyDetail.Add(entity);
LoadData();
}
这是新增数据代码,新增完成后重新绑定的时候出错
这是绑定表格的代码,打开窗口时绑定不会有问题
protected void LoadData()
{
InwardDetail entity = new InwardDetail();
entity = BllInwardDetail.SelectModel(Convert.ToInt32(hidId.Text));
string strWhere = " inwardId=" + entity.InwardId + " and SkuId=" + entity.SkuId + " and tallyStatus=2 ";
int pageCount;
Grid1.PageSize = BaseSystemInfo.pageSize;
IList<InwardTallyDetail> list = BllInwardTallyDetail.SelectByPage(Grid1.PageIndex, out pageCount, strWhere);
Grid1.RecordCount = pageCount;
if (list == null)
{
Grid1.DataSource = "";
}
else
{
Grid1.DataSource = list;
}
Grid1.DataBind();
}
|