Namespace tyj. Control
{
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;
Using System. Text;
Using BLL; // reference the custom business logic layer
/// <Summary>
/// Summary of bmxshow.
/// BMX English Web 'bussiness code class
/// Control code of BMX English website
/// By: http://www.itelite.cn
/// Time: 2007-10-25
/// </Summary>
Public class bmxshow: System. Web. UI. UserControl
{
Protected BMX_EN bmx_en = new BMX_EN (); // define a Business Object
Protected PagedDataSource PPS = new PagedDataSource (); // defines a paging record set
Protected DataSet ds = new DataSet ();
Protected DataTable dt = new DataTable ();
Private string navurl; // whether the paging tool button is displayed
Private bool dateshow; // whether to display the date
Private string newstype; // category of news displayed
Private int showsum;
Public string NavUrl {
Set {
Navurl = value;
}
Get {
Return navurl;
}
}
Public bool DateShow {
Set {
Dateshow = value;
}
Get {
Return dateshow;
}
}
Public string NewsType {
Set {
Newstype = value;
}
Get {
Return newstype;
}
}
Public int ShowSum {// number of records displayed
Set {
Showsum = value;
}
Get {
Return showsum;
}
}
Private void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
Shownews ();
}
# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor
/// Modify the content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. Load + = new System. EventHandler (this. Page_Load );
}
# Endregion
# Region self-compiled x
Protected void shownews ()
{
Ds = bmx_en.GetNewsList ("news_en", newstype );
Dt = ds. Tables [0];
If (showsum> dt. Rows. Count & showsum>-1)
{Showsum = dt. Rows. Count ;}
Else if (showsum <0)
{Showsum = 0 ;}
Response. Write ("<ul> ");
For (int I = 0; I <showsum; I ++)
{
HyperLink url = new HyperLink ();
// Response. Write ("<li> ");
Response. Write ("<li> <a href =" + navurl + "? Id = "+ dt. rows [I] ["newsid"]. toString () + ">" + dt. rows [I] ["newstitle"]. toString () + "_ hahha" + dt. rows [I] [2]. toString () + "</a> </li> ");
// How to add components dynamically
// Url. ToolTip = dt. Rows [I] ["newscreatedate"]. ToString ();
// Url. NavigateUrl = navurl + "? Id = "+ dt. Rows [I] [" newsid "]. ToString ();
// Url. Text = dt. Rows [I] ["newstitle"]. ToString ();
// This. Controls. Add (url );
// Add component end
Response. Write ("</li> ");
}
Response. Write ("</ul> ");
}
# Endregion
}
}