本文介绍了常见值的下拉问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有一个数据源的下拉列表,如

empname dept

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

Rahul 02

martin 01

sachin 02



我把这个表绑定了到我的下拉列表,当我尝试访问dept中的下拉选择事件更改每次我只得到Rahul。即使我选择了萨钦。



问题是什么?我假设我的数据值字段(02和02)中有两个常见值这是一个问题吗?



谢谢

Suresh

Hi I've a dropdown list with datasource like
empname dept
-----------------
Rahul 02
martin 01
sachin 02

i've binded this table to my dropdown list and when i try to access dept in dropdown selected event change everytime I'm gettin Rahul only. even i selected sachin.

Whats the problem? What I assume is I've two common values in my datavalue field (02 and 02) is this a problem?

Thank you
Suresh

推荐答案

DataSource,DataTextField,DataValueField
something like 
        ddlABC.Items.Add(new ListItem("--Please Select--", "0"));
        ddlABC.DataSource = <a list="" or="" datasource="">;
        ddlABC.DataTextField = "SomeName";
        ddlABC.DataValueField = "SomeID";
        ddlABC.DataBind();



if(!IsPostBack){
    DropDownList1.DataSource = YourDataSource;
    DropDownList1.DataTextField = "EmpName";
    DropDownList1.DataValueField = "Dept";
    DropDownList1.DataBind();
}





- Amit


这篇关于常见值的下拉问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 18:34