如何在GridView中将radiobuttonlist分配给boundfield?

时间:2016-03-15 12:46:41

标签: c# asp.net sql-server gridview sqldatasource

我将包含5列和50行的excel表导入数据表并将其存储在数据库表中。没有列是主键,因为它们包含字符串数据,重复,甚至允许空值。

例如:

EmpID | EmpName | Desig |部门|性别

是我表格中的列。

我使用SqlDataSource创建一个DataGrid,并使用Bound Fields将数据从DB表绑定到GridView。

例如:

<asp:BoundField DataField="EmpID" HeaderText="Employee ID" SortExpression="EmpID"/>

<asp:BoundField DataField="EmpName" HeaderText="Employee Name" SortExpression="EmpName"/

<asp:BoundField DataField="Desig" HeaderText="Designation" SortExpression="Desig"/>

<asp:BoundField DataField="Dept" HeaderText="Department" SortExpression="Dept"/>

<asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender"/>

性别列中的行完全为空,而其他行则包含一些数据。

我需要在GridView的Gender列的特定行中插入一个RadioButtonList,它满足EmpID列中以字母'A'开头的行/单元格的条件

例如:

Table

此外,在选择相应的单选按钮时,必须在数据库表中更新其值。

我如何实现这一目标?

1 个答案:

答案 0 :(得分:0)

你绝对应该使用TemplateColumn。