common.getlistdata

来源:百度知道 编辑:UC知道 时间:2024/07/02 01:21:01
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.CheckBoxList1.DataSource = Common.GetListData();

CheckBoxList1.DataTextField = "Text";
CheckBoxList1.DataValueField = "Value";
CheckBoxList1.DataBind();

}
}
protected void Button1_Click(object sender, EventArgs e)
{
string msg = "选中:<br><br>";
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
msg += CheckBoxList1.Items[i].Text + "<br>";
}

}
Response.Write(msg);
}
}
错误 1当前上下文中不存在名称“Common” C:\UsersDesktop\tess\CheckBoxlistD

using 少了

public partial class Default2 : System.Web.UI.Page
{
//Common应该是个类吧 有没有实例化
//比如:
CommonDAL Common=new CommonDAL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.CheckBoxList1.DataSource = Common.GetListData();

CheckBoxList1.DataTextField = "Text";
CheckBoxList1.DataValueField = "Value";
CheckBoxList1.DataBind();

}
}