简体   繁体   English

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

[英]How to assign a radiobuttonlist to a boundfield in GridView?

I imported an excel table consisting of 5 columns and 50 rows into a datatable and stored it in a database table. 我将由5列和50行组成的excel表导入到数据表中,并将其存储在数据库表中。 None of the columns are a primary key as they consist data of string, are repetitive and even allow null values. 没有列是主键,因为它们包含字符串数据,是重复的,甚至允许空值。

Eg: 例如:

EmpID | EmpID | EmpName | EmpName | Desig | Desig | Dept | 部门| Gender 性别

are the columns in my table. 是我表中的列。

I create a DataGrid with a SqlDataSource and Bind the data from the DB Table to the GridView using Bound Fields. 我使用SqlDataSource创建一个DataGrid,然后使用绑定字段将数据从数据库表绑定到GridView。

Eg: 例如:

<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"/>

Rows in the Gender column are completely null while others have some data into them. Gender列中的行完全为null,而其他行中有一些数据。

I need to insert a RadioButtonList in specific rows of the Gender column in the GridView which satisfy the condition of rows/cells in the EmpID column starting with the letter 'A' 我需要在GridView的Gender列的特定行中插入一个RadioButtonList,它满足EmpID列中以字母'A'开头的行/单元格的条件

Eg: 例如:

表

Also, on selecting the respective radiobutton, its value must be updated in the database table. 同样,在选择相应的单选按钮时,必须在数据库表中更新其值。

How do I achieve this? 我该如何实现这一目标?

您绝对应该使用TemplateColumn。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM