从后端的表中检索数据到dropdownlist控件

问题描述:

没有从后端的表格更新表单上的下拉控件



1. Id No:txt_Id



2.姓名:txt_Name



3性别:ddl_Gender





性别是一个下拉男/女作为嵌入的选项





表::试用



Idno姓名性别

----- -------------------

01保罗男

02常春藤女

03 Sal女士





除了下拉菜单外,所有其他控件都有效。



检查实习生的解决方案。示例不是很清楚。



请提供示例代码或参考资料



谢谢



C#

Not getting the dropdown control on the form updated from table in the backend

1. Id No: txt_Id

2. Name : txt_Name

3 Gender : ddl_Gender


The gender is a drop down that has male/female as the options embedded


Table :: Trial

Idno Name Gender
------------------------
01 Paul male
02 Ivy female
03 Sal female


All the other controls work with the exception of the drop down.

Checked on the internt for the solution. The examples were not very clear.

Please provide sample codes or a good reference

Thanks

new to C#

你应该为 DropDownList 男性女性



因为您直接存储男性女性作为字符串,所以您可以声明 DropDownList 物品的价值为男性女性



现在,当您从数据库中检索值时,您可以获得特定行的男性或女性。然后将其指定为 DropDownList SelectedValue 属性,以便选择正确的选项。
You should have two items declared for the DropDownList that are male and female.

As you are having directly stored male and female as strings, so you can declare the DropDownList items with value as male and female.

Now, when you retrieve the value from Database, you get either male or female for a particular row. Then just assign that as the SelectedValue property of the DropDownList so that correct option gets selected.