我有一个xtragrid,我填充并有2个未绑定的列。一切正常,除非我去过滤列,过滤的弹出窗口正确显示但是当我双击一个值时,我得到一个nullreference异常。我设法找到异常的位置,它在我的方法CustomColumnUnboundData中,我尝试从当前行获取当前对象,对象为null。你能帮助我吗?我究竟做错了什么 ? e.ListSourceRowIndex或GetRow()似乎不能用于过滤...
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
{
GridView gridView = (GridView)sender;
int dataSourceIndex = e.ListSourceRowIndex;
Person person = (Person)gridView.GetRow(dataSourceIndex);
if (e.Column.FieldName == "name" && e.IsGetData)
{
e.Value = person.PersonKey.Name;
}
if (e.Column.FieldName == "surname" && e.IsGetData)
{
e.Value = person.PersonKey.Surname;
}
}
答案 0 :(得分:0)
解决。
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e)
{
GridView gridView = (GridView)sender;
Person person = e.Row as Person;
//...
}