我正在尝试添加ASPxGridView
到页面并以ObjectDataSource
编程方式将其绑定。
这是我的代码:
protected void Page_Init(object sender, EventArgs e)
{
ObjectDataSource odsGroup = new ObjectDataSource();
var gridLookup = new ASPxGridView();
odsGroup.ID = "odsGroups";
odsGroup.SelectMethod = "GetAllElements";
odsGroup.TypeName = "Ifa.BusinessLayer.BLLClasses.GroupBll";
odsGroup.OldValuesParameterFormatString = "original_{0}";
gridLookup.ViewStateMode = ViewStateMode.Disabled;
gridLookup.ID = "groupsLookup";
gridLookup.AutoGenerateColumns = true;
gridLookup.DataSource = odsGroup;
gridLookup.KeyFieldName = "Id";
gridLookup.DataBind();
pnl1.Controls.Add(gridLookup);
}
GridView
当我使用而不是时,此代码工作正常ASPxGridView
,但正如我所说,它不适用于ASPxGridView
并抛出System.Runtime.Serialization.SerializationException
例外:
任何解决方案?