www.pudn.com > xiaoyuanwangzhan.rar > hotnews.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;
///
/// hotnews 的摘要说明。
///
public class hotnews : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
SqlConnection con=db.createcon();
// SqlCommand cmd=new SqlCommand("select * from hotnews ",con);
con.Open();
SqlCommand cmd=new SqlCommand("select * from hotnews",con);
string newstypename=Convert.ToString(cmd.ExecuteScalar());
// this.Label1.Text=newstypename;
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
}
}