获取listbox选中值? 查了半天也没能查到正确的方法那位帮下忙。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 you need to go through each item foreach (ListItem li in YourListBox.Items) { if (li.Selected) .... } or string[] s = Request.Form.GetValues(YourListBox.UniqueID); string[] s = Request.Form.GetValues(YourListBox.UniqueID);可能有问题,没有测试 服务器控件ListBox:this.ListBox1.selectitem.text;HTML控件;function getText(){document.getElementById("select1") 服务器控件ListBox:this.ListBox1.selectitem.text;HTML控件;function getText(){var select1=document.getElementById("select1");alert(select1options[select1selectedIndex].text);}刚刚没写完,BOSS来了 alert(select1options[select1.selectedIndex].text); TextBox1.Text = ListBox1.SelectedItem.Text;TextBox2.Text = ListBox1.SelectedItem.Value;上面的代码放到一个按钮的单击事件中,首先你的ListBox中要有项可供选择 -_-!!!BOSS来也不让上CSDN?我要从服务器端获取,不是从客户端获取我试了,,假如listbox是自己设定值的话,可以读出来但我现在是从数据库读取,再绑定到 listbox ,就读不出来值了很是奇怪~~ 为什么我可以啊,你是不是用的服务器控件ListBox,在SelectedIndexChanged事件中写的代码?AUTOPOSTBACK属性有没有改为TRUE 我的代码如下:foreach (ListItem li in hy1.Items) { if (li.Selected) { Response.Write(li.Value.ToString()); } } 解决了~~~是因为我把数词库中的数据绑定到 listbox 的时候写成了一个函数,当page_load的时候载入这个函数,忘记加 !ispostback 了。。汗~,不好意思,马上结帖~~ flash与asp.net程序如何交互。。 新人求助:Gridview的TemplateField 显示问题 [求助]vs2008 调用msnd非常慢! GridView如何突出显示当前页数? 关于DataView的一个小问题 数据类型转换 正则表达式问题。 为什么我的asp.net的网页在.NET开发环境中修改代码后,刷新浏览器不起作用,只有重新对这个网页进行“重新生成并浏览“才生效 求高手解答这个问题啊~~ 微信公众号一直是“请求URL超时”,请问怎么解决? |M| 为什么我照aspnetpager那样子给属性加DefaultValue 为什么我的无首效呢 url重写的问题
foreach (ListItem li in YourListBox.Items)
{
if (li.Selected)
....
}
or
string[] s = Request.Form.GetValues(YourListBox.UniqueID);
this.ListBox1.selectitem.text;
HTML控件;
function getText()
{
document.getElementById("select1")
this.ListBox1.selectitem.text;
HTML控件;
function getText()
{
var select1=document.getElementById("select1");
alert(select1options[select1selectedIndex].text);
}
刚刚没写完,BOSS来了
TextBox2.Text = ListBox1.SelectedItem.Value;上面的代码放到一个按钮的单击事件中,首先你的ListBox中要有项可供选择
{
if (li.Selected)
{
Response.Write(li.Value.ToString());
}
}