UI层
using System;
using System.Data;
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;
using BLL;
using MODEL;
namespace Admins{
public partial class manage_Manage_editnews : System.Web.UI.Page
{
private Bnews bn = new Bnews();
private Mnews mn = new Mnews(); 报错的地方
int nid = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
nid=Convert.ToInt32(Request.QueryString["nid"]);
newsshow();
}
} protected void newsshow()
{
if (nid>0)
{
mn = bn.selectnews(nid);
txtName.Text = mn.Title;
Content.Value = mn.Content;
hnid.Value = nid.ToString();
}
else
{
Basefun.showmessage("你还没有选择新闻!", "Manage_News.aspx");
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(hnid.Value);
if (txtName.Text!="" && Content.Value!="" && id>0)
{
bn.Updatenews(txtName.Text,Content.Value,id);
Basefun.showmessage("新闻修改成功!", "Manage_News.aspx");
}
else
{
Basefun.showmessage("请填入新闻的标题或内容!", "Manage_News.aspx");
}
}
}
}
MODEL层using System;
using System.Collections.Generic;
using System.Text;namespace MODEL
{
public class Mnews
{
private int id;
private string title, content, time; public int Id
{
set { id = value; }
get
{ return id; }
}
public string Title
{
get { return title; }
set { title = value; }
} public string Content
{
set { content = value; }
get { return content; }
}
public string Time
{
set { time = value; }
get { return time; }
}
public Mnews()
{ }
}
}
请各位多多帮忙了,谢谢谢谢谢!!
using System;
using System.Data;
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;
using BLL;
using MODEL;
namespace Admins{
public partial class manage_Manage_editnews : System.Web.UI.Page
{
private Bnews bn = new Bnews();
private Mnews mn = new Mnews(); 报错的地方
int nid = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
nid=Convert.ToInt32(Request.QueryString["nid"]);
newsshow();
}
} protected void newsshow()
{
if (nid>0)
{
mn = bn.selectnews(nid);
txtName.Text = mn.Title;
Content.Value = mn.Content;
hnid.Value = nid.ToString();
}
else
{
Basefun.showmessage("你还没有选择新闻!", "Manage_News.aspx");
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(hnid.Value);
if (txtName.Text!="" && Content.Value!="" && id>0)
{
bn.Updatenews(txtName.Text,Content.Value,id);
Basefun.showmessage("新闻修改成功!", "Manage_News.aspx");
}
else
{
Basefun.showmessage("请填入新闻的标题或内容!", "Manage_News.aspx");
}
}
}
}
MODEL层using System;
using System.Collections.Generic;
using System.Text;namespace MODEL
{
public class Mnews
{
private int id;
private string title, content, time; public int Id
{
set { id = value; }
get
{ return id; }
}
public string Title
{
get { return title; }
set { title = value; }
} public string Content
{
set { content = value; }
get { return content; }
}
public string Time
{
set { time = value; }
get { return time; }
}
public Mnews()
{ }
}
}
请各位多多帮忙了,谢谢谢谢谢!!
解决方案 »
- 分享+思考:真静态和伪静态
- 新手SELECT里加号双引号求助
- 请求页只输出需要的内容给ajax请求返回
- 如何将System.Data.OracleClient.OracleParameter 类型的对象保存在viewstate里面?
- 不可访问“System.Data.SqlClient.SqlConnection.SqlConnection(System.Data.SqlClient.SqlConnection)”,因为它受保护级别限制
- imagebutton控件的问题求教!
- Aspose.cells模板导出Excel如何保留下拉框?
- 如何得到页面焦点控件的id并为其设置值
- 为什么我用Server.MapPath(""),返回不了任何东东?
- 简单问题,答对解释清楚马上给分。Requiredfieldvalidator页面验证的问题
- 100分求解!!
- 用C# LastAccessTime和右键点击文件属性中的访问时间不一致
using BLL;
using MODEL;
namespace Admins{
下面的一行是不是有误?
public Mnews()
{
}
using System.Data;
using System.Web;
using System.Data.OleDb;
using IDAL;
using MODEL;
using DALFactory;
namespace BLL
{
public class Bnews
{
private static readonly IDnews bn = DataAcess.Createnews();
public Bnews()
{ }
public DataTable getnews()
{
return bn.getnewstable();
}
public void Updatenews(string title, string content, int id)
{
if (title != "" && content != "" && id > 0)
{
Mnews mn = new Mnews();
mn.Title = title;
mn.Content = content;
mn.Id = id;
bn.updatenews(mn);
}
}
public Mnews selectnews(int id)
{
if (id>0)
{
DataRow dr = bn.selectnewsRow(id);
Mnews mn = new Mnews();
mn.Title = dr["title"].ToString();
mn.Content = dr["content"].ToString();
return mn;
}
return null; } }
}
在你的UI层项目里,搜索下"Mnews"吧
public partial class manage_Manage_editnews : System.Web.UI.Page
{
private Bnews bn = new Bnews();
// private Mnews mn = new Mnews(); // <-- 报错的地方,这句注释掉。
private MODEL.Mnews mn = new MODEL.Mnews(); // <-- 这样不会报错。
private Admins.Mnews amn = new Admins.Mnews(); // <-- 加上这句看看,
// 如果不报错,说明 AAdmins 里面重复定义了 Mnews 。
}