Sys.WebForms. проблема. Я пытался сузить вопрос о «rsvpCountry», но я не вижу, где проблема. Любая помощь, пытающаяся выяснить, как решить эту ошибку, будет очень признательна, так как мне нужно Обновление для работы содержимого строки.
<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound"
AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" OnDataBound="GridView1_DataBound" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"></asp:ObjectDataSource>
и код за страницей (.cs ) назначает содержимое для ObjectDataSource
.
protected _MyENT obj = new _MyENT();
protected _MyBLL bll = new _MyBLL();
protected void Page_Load(object sender, EventArgs e)
{
//lblTitle.Text = obj.GetType().ToString();
ObjectDataSource1.DataObjectTypeName = obj.GetType().ToString();
ObjectDataSource1.TypeName = bll.GetType().ToString();
ObjectDataSource1.SelectMethod = "GetData";
ObjectDataSource1.InsertMethod = "Insert";
ObjectDataSource1.UpdateMethod = "Update";
ObjectDataSource1.DeleteMethod = "Delete";
}
Вот код файла BLL, касающийся метода «Обновление»:
[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
public bool Update(_MyENT ent)
{
MyXSD.MyDataTable table = Adapter.GetData();
foreach (Rsvp.MyRow row in table.Rows)
{
if (row.id == ent.id)
{
try
{
row.InviteeID = ent.InviteeID;
row.rsvpFirstName = ent.rsvpFirstName;
row.rsvpLastName = ent.rsvpLastName;
row.rsvpTitle = ent.rsvpTitle;
row.rsvpAddress1 = ent.rsvpAddress1;
row.rsvpAddress2 = ent.rsvpAddress2;
row.rsvpAddress3 = ent.rsvpAddress3;
row.rsvpAddress4 = ent.rsvpAddress4;
row.rsvpCity = ent.rsvpCity;
row.rsvpState = ent.rsvpState;
row.rsvpZip = ent.rsvpZip;
row.rsvpCountry = ent.rsvpCountry;
row.rsvpTel = ent.rsvpTel;
row.rsvpEmail = ent.rsvpEmail;
row.rsvpType = ent.rsvpType;
row.rsvpConfirmationSent = ent.rsvpConfirmationSent;
row.rsvpYes = ent.rsvpYes;
row.dinnerYes = ent.dinnerYes;
row.lectureYes = ent.lectureYes;
row.receptionYes = ent.receptionYes;
row.guestOfID = ent.guestOfID;
row.mealPreference = ent.mealPreference;
}
catch (Exception x)
{
return false;
}
row.updated = DateTime.Now;
}
}
int rowsAffected = Adapter.Update(table);
return rowsAffected == 1;
}
, а вот файл ENT:
public class _MyENT
{
public _MyENT()
{
//
// TODO: Add constructor logic here
//
}
private int _id;
private int _InviteeID;
private string _rsvpFirstName;
private string _rsvpLastName;
private string _rsvpTitle;
private string _rsvpAddress1;
private string _rsvpAddress2;
private string _rsvpAddress3;
private string _rsvpAddress4;
private string _rsvpCity;
private string _rsvpState;
private string _rsvpZip;
private string _rsvpCountryCode;
private string _rsvpTel;
private string _rsvpEmail;
private byte _rsvpType;
private bool _rsvpConfirmationSent;
private bool _rsvpYes;
private bool _lectureYes;
private bool _dinnerYes;
private string _mealPreference;
private bool _receptionYes;
private int _guestOfID;
private string _guestOfName;
private DateTime _updated;
public int id { get { return _id; } set { _id = value; } }
public int InviteeID { get { return _InviteeID; } set { _InviteeID = value; } }
public string rsvpFirstName { get { return _rsvpFirstName; } set { _rsvpFirstName = value; } }
public string rsvpLastName { get { return _rsvpLastName; } set { _rsvpLastName = value; } }
public string rsvpTitle { get { return _rsvpTitle; } set { _rsvpTitle = value; } }
public string rsvpAddress1 { get { return _rsvpAddress1; } set { _rsvpAddress1 = value; } }
public string rsvpAddress2 { get { return _rsvpAddress2; } set { _rsvpAddress2 = value; } }
public string rsvpAddress3 { get { return _rsvpAddress3; } set { _rsvpAddress3 = value; } }
public string rsvpAddress4 { get { return _rsvpAddress4; } set { _rsvpAddress4 = value; } }
public string rsvpCity { get { return _rsvpCity; } set { _rsvpCity = value; } }
public string rsvpState { get { return _rsvpState; } set { _rsvpState = value; } }
public string rsvpZip { get { return _rsvpZip; } set { _rsvpZip = value; } }
public string rsvpCountry { get { return _rsvpCountryCode; } set { _rsvpCountryCode = value; } }
public string rsvpTel { get { return _rsvpTel; } set { _rsvpTel = value; } }
public string rsvpEmail { get { return _rsvpEmail; } set { _rsvpEmail = value; } }
public byte rsvpType { get { return _rsvpType; } set { _rsvpType = value; } }
public bool rsvpConfirmationSent { get { return _rsvpConfirmationSent; } set { _rsvpConfirmationSent = value; } }
public bool rsvpYes { get { return _rsvpYes; } set { _rsvpYes = value; } }
public bool lectureYes { get { return _lectureYes; } set { _lectureYes = value; } }
public bool dinnerYes { get { return _dinnerYes; } set { _dinnerYes = value; } }
public string mealPreference { get { return _mealPreference; } set { _mealPreference = value; } }
public bool receptionYes { get { return _receptionYes; } set { _receptionYes = value; } }
public int guestOfID { get { return _guestOfID; } set { _guestOfID = value; } }
public string guestOfName { get { return _guestOfName; } set { _guestOfName = value; } }
public DateTime updated { get { return _updated; } set { _updated = value; } }
}