www.pudn.com > xiaoyuanwangzhan.rar > news.ascx.cs
namespace newsystem.mycontrols
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
///
/// news 的摘要说明。
///
public class news : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
private string newstypeid;
public string Newstypeid
{
set
{
this.newstypeid=value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
SqlConnection con=db.createcon();
SqlCommand cmd=new SqlCommand("select newstypename from newstype where newstypeid='"+this.newstypeid+"'",con);
con.Open();
string newstypename=Convert.ToString(cmd.ExecuteScalar());
this.Label1.Text=newstypename;
// cmd.CommandText="select top 3 newstitle from newsmaster where newstypeid='"+this.newstypeid+"' order by newstypeid desc";
cmd.CommandText="select * from newsmaster where newstypeid='"+this.newstypeid+"' order by updatetime desc";
this.DataGrid1.DataSource=cmd.ExecuteReader();
this.DataGrid1.DataBind();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}