【发布时间】:2014-01-19 00:14:08
【问题描述】:
当我尝试使用CheckBoxList1.SelectedItem.Value 时,它给了我错误。我有点困惑并浏览了这本 Murach ASP.Net 书,但我没有看到任何答案。我想要在我的 ListBox 中选择什么以及在我的 CheckBox 中选择什么并添加它们。有什么帮助吗?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int ucost = int.Parse(DropDownList1.SelectedItem.Value);
int ccost = int.Parse(//what does in here???);
ttbox.Text = ccost.ToString();
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
ttbox.Text = "";
}
protected void ttbox_TextChanged(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
这是一个更新。他们说一张照片值一千字。
【问题讨论】:
-
你想从复选框列表中获取最后选择的项目吗?
-
不,我想要的是,例如,假设用户点击了周五午餐的第一个复选框。它的值是 8。我想将 8 添加到我的列表框值的值上。
标签: c# asp.net checkbox listbox