【发布时间】:2012-01-12 19:45:53
【问题描述】:
我在数据网格模板字段中有一个下拉列表控件。在 SelectedIndexChanged 事件中,我只想获取发送者对象的位置,以便创建对发送者对象所在行的引用。我在谷歌上发现的只是如何遍历数据网格的每一行以进行比较它到发件人的客户端 ID 以查看它是否实际上是我选择的行。为什么我不能只获取发送者对象的位置并使用它来创建该 gridviewrow 的实例?为什么以下不起作用?
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.SelectedRow;
var store = row.Cells[0].Text; //I get the Object reference not set to an instance of an object error here
}
我错过了什么吗?
【问题讨论】: