从后端的表中检索数据到dropdownlist控件 [英] retrieving data into dropdownlist control from table in back end

查看:74
本文介绍了从后端的表中检索数据到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 <声明两个项目/ code> 男性女性



因为您直接存储男性女性作为字符串,所以您可以声明 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.


这篇关于从后端的表中检索数据到dropdownlist控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆