62,041
社区成员
发帖
与我相关
我的任务
分享
Response.Write("<table>");
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
Response.Write("<tr>");
for(int k=0;k<=5;k++)
{
Response.Write("<td>"+ds.Tables[0].Rows[i][k].ToString()+"</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>");
BJProduct Product = new BJProduct();
BJProductCategory Category = new BJProductCategory();
//int id;
int cid;
DataTable myDataTable = new DataTable();
DataColumn myDataColumn = new DataColumn();
DataRow MyRow;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShowCategory();
}
}
//得到产品类别ID然后显示下级分类信息,根据下级分类类别得到该类别下的产品
protected void ShowCategory()
{
int row;
Category.ParentID = 62;
DataTable dt1 = WebManager.List(Category, "", "[ID],[Title],[ParentID]", "&parentid=", "[OrderNo]");
row = dt1.Rows.Count;
if (dt1.Rows.Count > 0)
{
AddDataTable();
for (int i = 0; i < dt1.Rows.Count; i++)
{
int a = Convert.ToInt32(dt1.Rows[i][0].ToString());
Product.ParentID = a;
DataTable dt = WebManager.List(Product, "", "[ID],[Title],[PictureUrl]", "&parentid=", "[OrderNo]");
if (dt.Rows.Count > 0)
{
for (int n = 0; n < dt.Rows.Count; n++)
{
MyRow = myDataTable.NewRow();
MyRow["ID"] = dt.Rows[n][0].ToString();
MyRow["Title"] = dt.Rows[n][1].ToString();
MyRow["PictureUrl"] = dt.Rows[n][2].ToString();
myDataTable.Rows.Add(MyRow);
}
}
ShowProductInfo();
}
}
}
//建一个数据表
protected void AddDataTable()
{
//编号
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "ID";
myDataTable.Columns.Add(myDataColumn);
//标题
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Title";
myDataTable.Columns.Add(myDataColumn);
//图片
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "PictureUrl";
myDataTable.Columns.Add(myDataColumn);
}
//显示解决方案类别下的产品信息
protected void ShowProductInfo()
{
//Product.ParentID = cid;
//DataTable dt = WebManager.List(Product, "", "[ID],[Title],[PictureUrl]", "&parentid=", "[OrderNo]");
DLProductInfo.DataSource = myDataTable;
Ascpager1.DataSource = myDataTable.DefaultView;
DLProductInfo.DataSource = Ascpager1.PageDataSource;
DLProductInfo.DataBind();
}
if(!IsPostBack)
{
//取dataset
DataSet ds;
string outmodel = "<table><tr><td>{0}</td><td>{1}</td></tr></table>";//根据你要求改动
string outhtml ="";
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
DataRow dr = ds.Tables[0].Rows[i];
outhtml += string.Format(outmodel,dr[0],dr[1]);//dr["fieldname"]
}
this.litRows.Text = outhtml;
ds.Dispose();
}