Asp.net C#从dropdownlist中获取数据显示在标签中 [英] Asp.net C# fetch data from dropdownlist show in label

查看:422
本文介绍了Asp.net C#从dropdownlist中获取数据显示在标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个下拉列表

< asp:DropDownList ID =ddlFranchiserunat =server>
< asp:ListItem> Canada< / asp:ListItem>
< asp:ListItem> India< / asp:ListItem>
< asp:ListItem> USA< / asp:ListItem>
< / asp:DropDownList>



这些在标签中显示如

加拿大(Label1):

印度(Label2):

美国(Label3):





我的尝试:



没什么

解决方案

你好b $ b

我会假设你使用过JQuery之前。如果你还没有请谷歌。您可以使用标签的ID /名称来显示下拉列表中的值。



您可以从下拉列表中获取值,如下所示:

 


#ddlFranchise)。val()





然后,您可以将此选定值设置为任何标签如下:

 


#label1的)。文本(

 there is a dropdownlist
 
<asp:DropDownList ID="ddlFranchise" runat="server" >
<asp:ListItem>Canada</asp:ListItem> 
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>USA</asp:ListItem> 
</asp:DropDownList>
 
 
 
these  show  in label like
 
Canada(Label1) :
 
India (Label2) :
 
USA (Label3) :



What I have tried:

Nothing

解决方案

Hi
I will assume you have worked with JQuery before. If you have not please Google it. what you can do is use the ID/Name of your label to display the value from the drop down.

You can get a value from the dropdown as follows:


("#ddlFranchise").val()



You can then set this selected value to any of your labels as follows:


("#label1").text(


这篇关于Asp.net C#从dropdownlist中获取数据显示在标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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