如何在下拉列表中添加该功能 [英] how to add the function in the dropdownlist

查看:91
本文介绍了如何在下拉列表中添加该功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写的功能如下



private void dropdownfill(DropDownList Dname)

{



Dname.Items.Clear();

Dname.Items.Add( - 选择评分 - );

Dname.Items .Add(Excellent);

Dname.Items.Add(Very Good);

Dname.Items.Add(Good);

Dname.Items.Add(公平);

Dname.Items.Add(差);



}



然后我有三个下拉列表如下



Dropdownlist1

Dropdownlist2

下拉列表3


上述3下拉列表中的
我希望评分如下



优秀

很好

好​​

公平





例如Dropdownlist1如下



Dropdownlist1(优秀)

(非常好)

(好)

(公平)

(差)





我怎样才能在asp.net中使用csharp。



问候,

Narasiman P.

I written the function as follows

private void dropdownfill(DropDownList Dname)
{

Dname.Items.Clear();
Dname.Items.Add("--Select Grading--");
Dname.Items.Add("Excellent");
Dname.Items.Add("Very Good");
Dname.Items.Add("Good");
Dname.Items.Add("Fair");
Dname.Items.Add("Poor");

}

Then i have three dropdownlist as follows

Dropdownlist1
Dropdownlist2
Dropdownlist3

in the above 3 Dropdownlist i want the Grading as follows

Excellent
Very Good
Good
Fair
Poor

For Example Dropdownlist1 as follows

Dropdownlist1 ("Excellent")
("Very Good")
("Good")
("Fair")
("Poor")


for that how can i do in asp.net using csharp.

Regards,
Narasiman P.

推荐答案

嗨Narasiman,



我尝试了一些符合您要求的代码,试试这个

Hi Narasiman,

I tried some code for your requirement, try this
public void Page_Load(object sender, EventArgs e)
       {
           List<string> strVal=new List<string>();
           strVal.Add("Excellent");
           strVal.Add("Good");
           strVal.Add("Super");
           strVal.Add("Average");
           strVal.Add("Bad");
           BindDDLValue(strVal,DropDownList1);
           BindDDLValue(strVal, DropDownList2);
           BindDDLValue(strVal, DropDownList3);
       }

       private void BindDDLValue(List<string> listVal, DropDownList ddl)
       {
           if (ddl != null)
           {
               ddl.DataSource = listVal;
               ddl.DataBind();
           }
       }



我认为这符合您的要求。尝试这个和lemme知道。

您可以将任意数量的下拉控件传递给它将绑定的方法并将其交还给您。



问候,

RK


Which will apt to your requirement I believe. try this and lemme know.
You can pass any number of dropdown control to the method it will bind and give it back to you.

Regards,
RK


这篇关于如何在下拉列表中添加该功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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