checkedListBox中如何删除被选择的项目
我做的不实web的if(test123.SelectedItem.Selected.ToString()=="True"){test123.Items.Remove(te...
我做的不实web的
if (test123.SelectedItem.Selected.ToString() == "True")
{
test123.Items.Remove(test123.SelectedItem.Text.ToString());
}
不好用阿 展开
if (test123.SelectedItem.Selected.ToString() == "True")
{
test123.Items.Remove(test123.SelectedItem.Text.ToString());
}
不好用阿 展开
展开全部
test.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="News_System_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList runat="server" ID="test123">
<asp:ListItem>test1</asp:ListItem>
<asp:ListItem>test2</asp:ListItem>
<asp:ListItem>test3</asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>
test.aspx.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
public partial class News_System_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (test123.SelectedItem.Selected.ToString() == "True")
{
test123.Items.Remove(test123.SelectedItem.Text.ToString());
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="News_System_test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList runat="server" ID="test123">
<asp:ListItem>test1</asp:ListItem>
<asp:ListItem>test2</asp:ListItem>
<asp:ListItem>test3</asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>
test.aspx.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
public partial class News_System_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (test123.SelectedItem.Selected.ToString() == "True")
{
test123.Items.Remove(test123.SelectedItem.Text.ToString());
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询