asp.net 如何取得ListBox选中的值? 按钮里取不到listbox选中的值,老是出现默认的值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不会啊,你要找对方法啊有一个属性可以获取或设置listbox当前值,我忘了,你仔细找找吧。。 先点击listbox 在它的属性里找到text把text里面的数据清空掉,然后在后台代码比如说 textbox 来获取listbox中选中的值就这样写,textbox = listbox.Text;就OK了 贴代码出来,,,看看到底什么情况string strValue = ListBox1.SelectedItem.Value;//这就是ListBox选中的值 for(int i=0;i<ListBox1.Items.Count;i++ ) { if (ListBox1.Items[i].Selected) Response.Write(ListBox1.Items[i].Text); } listBox1.SelectedItem.ToString() page_load 事件代码中要加上if(!IsPostBack){ 你原有的代码} if (!IsPostBack) {绑定checkboxlist的代码}protected void btn_Click(object sender, EventArgs e) { ListBox1.SelectedValue.ToString();///取到的是默认的值,也就是是第一个值} protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ListBox1.Items.Clear(); ListItem li = new ListItem("A","1"); ListBox1.Items.Add(li); ListItem lii = new ListItem("B", "2"); ListBox1.Items.Add(lii); } } protected void Button1_Click(object sender, EventArgs e) { string value = ListBox1.SelectedValue.ToString(); }我可以获得啊 自定义控件中图片不能正常显示问题!!!! 平时写代码要想半天 .net下js出错 是否在预览文件前保存更改 提示 时间无法显示 查看OFFICE文档的组件? 问了三次了,没有解决 我为何引入System.Data.ADO错误! 不能以方法的方式使用不可调用的“System.Data.DataTable.Rows”。 一开始web页面正常,后来我加入一个复制的panel和table,结果导致不正常,反复次无效 急急急!一个关于判断格式是否正确的问题.在线等!! 用linq怎么操作list?
{
if (ListBox1.Items[i].Selected) Response.Write(ListBox1.Items[i].Text);
}
listBox1.SelectedItem.ToString()
要加上
if(!IsPostBack)
{
你原有的代码
}
if (!IsPostBack)
{
绑定checkboxlist的代码
}
protected void btn_Click(object sender, EventArgs e)
{
ListBox1.SelectedValue.ToString();///取到的是默认的值,也就是是第一个值
}
{
if (!IsPostBack)
{
ListBox1.Items.Clear();
ListItem li = new ListItem("A","1");
ListBox1.Items.Add(li);
ListItem lii = new ListItem("B", "2");
ListBox1.Items.Add(lii);
}
} protected void Button1_Click(object sender, EventArgs e)
{
string value = ListBox1.SelectedValue.ToString();
}我可以获得啊