单击“保存”按钮时出现可序列化错误 [英] serializable error came on clicking on save button

查看:70
本文介绍了单击“保存”按钮时出现可序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,我点击该按钮时保存按钮我必须在视图状态上广告,并在最后提交视图状态的整个数据必须保存但错误发生在视图上保存日期错误状态在程序集'AccountOperation中输入'CoSys.AccountOperation.DAL.AcoTransaction',Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'未标记为可序列化。





我的代码在这里



I have a page and i have the save button on clicking on that button i have to ad on view state and on last on submit the whole data of view state has to be saved but the error came on saving the date on view state of error "Type 'CoSys.AccountOperation.DAL.AcoTransaction' in Assembly 'AccountOperation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable."


my code is here

private List<AcoTransaction> AcoTrans
   {
       get
       {
           if (ViewState["AcoTransaction"] == null)
           {
               ViewState["AcoTransaction"] = new List<AcoTransaction>();
           }
           return (List<AcoTransaction>)ViewState["AcoTransaction"];
       }
       set
       { ViewState["AcoTransaction"] = value; }
   }













protected void btnSavingAmountDeposit_Click(object sender, EventArgs e)
   {
           ConfirmationMessageCashReceived.Visible = true;
           uc = new UserCredential();
           ucTO = uc.GetUserCredential();
           this.Page.Validate();

           ltrMessageCashReceived.Text = string.Empty;
           bool aDeposit = IsNumeric(txtDepositedAmount.Text);
           cAcoDayOpenAndClose = new CAcoDayOpenAndClose(HttpContext.Current.Request.RawUrl);
           var acoDayOpenAndClose = cAcoDayOpenAndClose.GetActiveOpenedDate();
           if (acoDayOpenAndClose != null)
           {
               cMemMemberRegistration = new CMemMemberRegistration(HttpContext.Current.Request.RawUrl);
               var memMemberRegistration = cMemMemberRegistration.GetByMemMemberRegistrationId(Convert.ToInt64(hfdMemberRegistrationId.Value));
               if (hfdMemberRegistrationNo.Value == "" || hfdMemberRegistrationId.Value == "0" || hfdMemberRegistrationId.Value == null || memMemberRegistration == null)
               {
                   ltrMessageCashReceived.Text = "Please Enter Correct MemberId";
                   txtMemberId.Focus();
               }
               else if (ListBoxSavingAcNo.SelectedValue == "-1" || ListBoxSavingAcNo.SelectedValue == null || ListBoxSavingAcNo.SelectedValue == "")
               {
                   ltrMessageCashReceived.Text = "Please Choose Correct Account No";
                   ListBoxSavingAcNo.Focus();
               }
               else
               {
                   if (aDeposit == true)
                   {

                       if (Convert.ToDecimal(txtDepositedAmount.Text.Trim()) <= 0)
                       {
                           ltrMessageCashReceived.Text = "Please Enter Correct Amount";
                           txtDepositedAmount.Focus();
                       }
                       else if (Convert.ToDouble(txtDepositedAmount.Text) > Convert.ToDouble(txtBalanceAmount.Text))
                       {
                           ltrMessageCashReceived.Text = "Please Enter Correct Submitted Amount";
                           txtDepositedAmount.Focus();
                       }
                       else
                       {

                           
                           AcoTransaction AddData = new AcoTransaction();
                           AddData.AcoTransactionId = -1;
                           AddData.MemMemberRegistrationId = Convert.ToInt64(hfdMemberRegistrationId.Value);
                           AddData.MamAccountOpeningId = Convert.ToInt64(ListBoxSavingAcNo.SelectedValue);
                           AddData.AcoTransactionTypeId = Convert.ToInt64(1);
                           AddData.HurCollectorId = Convert.ToInt64(ddlCollector.SelectedValue);
                           AddData.CashReceived = Convert.ToDecimal(txtSubmittedAmount.Text.Trim());
                           AddData.IsPosted = false;
                           AddData.CreatedBy = ucTO.UserId;
                           AddData.CreatedOn = System.DateTime.Now;
                           AddData.IsCancelled = false;
                           AcoTrans.Add(AddData);
                           //BindCashReceivedToGrid();

                       }
                   }
                   else
                   {
                       ltrMessageCashReceived.Text = "Please Enter Submitted Amount in Numbers";
                       txtDepositedAmount.Focus();
                   }
               }
           }
           else
           {
               ltrMessageCashReceived.Text = "Transection Date not Opened for Cash Received";
           }

   }

推荐答案

将以下属性添加到 AcoTransaction 类代码:

Add the following attribute to the AcoTransaction class code:
[Serializable] // this is required for some serializers
public class AcoTransaction 
{
...


这篇关于单击“保存”按钮时出现可序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆