62,073
社区成员
发帖
与我相关
我的任务
分享
using System.Data;
using System.Configuration;
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 MySql.Data.MySqlClient;
/// <summary>
/// Business 的摘要说明
/// </summary>
public class Business
{
DataBase db = new DataBase();
public Business()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public DataSet GetPro(string strSQL,string TableName)
{
MySqlConnection conn = db.MyConnection();
MySqlDataAdapter da = new MySqlDataAdapter(strSQL,conn);
DataSet ds = new DataSet();
da.Fill(ds,TableName);
return ds;
}
public MySqlDataReader ShowList(string ssql)
{
MySqlConnection conn = db.MyConnection();
MySqlCommand comm = new MySqlCommand(ssql, conn);
try
{
conn.Open();
MySqlDataReader dr = comm.ExecuteReader();
return dr;
}
catch (Exception X)
{
throw X;
}
finally
{
conn.Close();
comm.Dispose();
}
}
}
select * from 表 where Phone='Nokia'
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
this.ShowProducts();
JYKPage1.ControlGridID = "DataList1";
this.SetPageInfo();
}
}
private void ShowProducts()
{
string ssql = "select id,ProductSerial,ProductName,PicUrl from products";
DataSet ds = db.GetDataSet(ssql,"b");
this.DataList1.DataSource = ds.Tables["b"].DefaultView;
this.DataList1.DataBind();
}
public static string PLeft(object Content, int length)
{
if ((Content == null) || !(Content is string))
{
return string.Empty;
}
if (((string)Content).Length > length)
{
Content = ((string)Content).Substring(0, length) + "...";
}
return (string)Content;
}
private void SetPageInfo()
{
JYKPage1.TableName= "products"; //表名或者视图名
JYKPage1.TableShowColumns = "id,ProductSerial,ProductName,PicUrl"; //显示的字段
JYKPage1.TableIDColumns = "id"; //主键
JYKPage1.TableOrderColumns = "id";//排序字段
JYKPage1.PageSize = 10;//一页的记录数
JYKPage1.NaviCount = 5; //页号导航的数量
this.JYKPage1.TableQuery = ""; //查询条件
JYKPage1.BindFirstPage();////显示第一页的数据
}
<cc1:JYKPage ID="JYKPage1" runat="server" />
<appSettings>
<add key="DataType" value="1"/>
</appSettings>