简体   繁体   中英

DataTextField and DataValueField properties of DropDownList

Every one says that, you have people in your database and in this case the DataValueField can be the ID of the person and the DataTextField can be the name of the person in your DropDownList .

But I want to know that if I don't have any ID type field then what will be my DataValueField ?

Column in my database are UserName , Password , UserType . What will be my DataTextField & DataValueField ?

Well, it does not mean that you should have a field named Id but you need a field that has a unique value. So the Primary Key is the best option for it whether its named Id or anything else.

As the UserName is the Primary Key so you can use it as the DataValueField.

在您的情况下,请将“ UserName”设置为DataValueField和DataTextField。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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