这是一个新闻管理系统,主页面单击新闻时,显示一个新闻内容对话框,
index.aspx.cs内容如下:
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 System.Data.SqlClient;
public partial class index : System.Web.UI.Page
{
commonclass cc = new commonclass();
protected void Page_Load(object sender, EventArgs e)
{
//时政要闻
dlsz.DataSource = cc.GetDataSet("select top 5 * from tb_news where style='时政要闻' order by id desc","tb_news");
dlsz.DataKeyField = "ID";
dlsz.DataBind();
}
protected void dlsz_ItemCommand(object source, DataListCommandEventArgs e)
{
int ID = Convert.ToInt32(dlsz.DataKeys[e.Item.ItemIndex].ToString());
Response.Write("");
}
}
shownews.aspx.cs内容如下
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 System.Data.SqlClient;//添加类库
public partial class showNews : System.Web.UI.Page
{
commonclass cc = new commonclass();
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = cc.GetDataSet("select * from tb_News", "tb_News");
DataRow[] row = ds.Tables["tb_News"].Select("id=" + Request.QueryString["id"]);
foreach (DataRow rs in row)
{
this.Page.Title = rs["title"].ToString();
this.labTitle.Text = rs["title"].ToString();
this.txtContent.Text =""+ rs["content"].ToString();
}
}
protected void btnClose_Click(object sender, EventArgs e)
{
Response.Write("");
}
}
请高手帮忙!
DataRow[] row = ds.Tables["tbNews"].Select("id=" + Request.QueryString["id"]);
这句出错了
|