1. 首先在初始化Gridview时候定义主键的数组。
GridViewTeacherStudent.DataKeyNames=new string[] {"courseId","studentId","type","level","unit"};
2. 在进行删除操作,或者对某行进行操作获得列中的值。
string studentId = GridViewTeacherStudent.DataKeys[e.RowIndex]["studentId"].ToString().Trim();
3.如果只有单个的键值时候。如只有”StudentId“一个主键下面直接获得。
string studentId = GridViewTeacherStudent.DataKeys[e.RowIndex].Value.ToString().Trim();
本文介绍如何在GridView中配置多个主键字段,并演示了如何通过这些主键获取特定行的数据,包括删除操作和获取指定列的值。
227

被折叠的 条评论
为什么被折叠?



