Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从处于编辑模式且用户单击“更新”的 GridView 行中获取基础 DataItem?
我有一个可编辑的 GridView。我已将 CustomValidator 添加到其中一列的编辑视图中。当用户单击更新时,我运行服务器验证方法并需要获取正在编辑的行的底层 DataItem,以便我可以获得数据项的主键以用于验证。
GridView1.Rows[GridView1.EditIndex].DataItem;
这不起作用。我猜是因为 GridView 没有在更新命令上进行数据绑定?
GridView1.DataKeys[GridView1.EditIndex].Value;
我有一个类似的问题。我使用 rowdatabound 事件而不是 gridview 的更新事件。
这是一个例子
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.dataitem%28VS.80%29.aspx#