[0]是指当前行第1列的单元格位置

注意:DataRowView要求必须引用System.Data命名空间

方法一:

DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem;
int result = Convert.ToInt32(mySelectedElement.Row[0]);

方法二:

var a = this.dataGrid1.SelectedItem;
var b = a as DataRowView;
int result = Convert.ToInt32(b.Row[0]);

posted on 2011-04-26 22:42  dinid  阅读(13696)  评论(1编辑  收藏  举报