“System.Web.UI.Control”并不包含“Checked”的定义?
各位大哥帮我看一下这个错误怎么解決?
我是想点击delete(button控件)的時候,把datalist1里的checkbox.checked为true的记录都删掉。
编译器错误信息: CS0117: “System.Web.UI.Control”并不包含“Checked”的定义
行 40: foreach(DataListItem ChlItem in DataList1.Items)
行 41: {
行 42: bool IsCheck=(CheckBox)(ChlItem.FindControl( "DeleteOrNot ")).Checked; //此行红色,难道这一行有错?
行 43:
行 44: if (IsCheck)
.cs部分代码
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class checkbox_delete : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection( "Data Source=.;Initial Catalog=9957_PRODUCT_SMS;Integrated Security=True ");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindtosource();
}
}
protected void bindtosource()
{
SqlCommand comm = new SqlCommand( "select 身份证号码,学生姓名 from 学生 ", conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
DataList1.DataSource = dr;
DataList1.DataBind();
conn.Close();
}
protected void delete_Click(object sender, EventArgs e)
{
foreach(DataListItem ChlItem in DataList1.Items)
{
bool IsCheck=(CheckBox)(ChlItem.FindControl( "DeleteOrNot ")).Checked;
if (IsCheck)