【发布时间】:2011-06-29 20:57:05
【问题描述】:
场景
我将DataGrid 与包含DropDownList 的列一起使用。当我更新值时,DropDownList 值不会更新。
我目前的研究
我相信它需要一些 C# 代码才能使 DropDownList 可编辑。我不知道将代码放在哪里以及如何放置?有比 C# 代码更短的方法吗?
非常感谢
编辑:提供的代码
student_table : id, name, major, favorite_teacher
teacher_table : id, name
gridview 有学生的数据源。 DropDownList 有教师的数据源。
在 gridview 中,我将 favorite_teacher 作为模板字段 (DropDownList) 并将teacher_table 作为数据源。在编辑模式下,DropDownList 显示正确并从教师表中填充教师。当我为任何学生选择最喜欢的老师并单击提交时,提交没有通过。我可能需要一些 C# 代码或其他。不知道如何解决这个问题。
【问题讨论】:
标签: c# gridview drop-down-menu