一个列表的问题?

gugh 2004-08-11 04:35:15
请问这种列表显示(页面中间的商品分类) 是怎样实现的 http://www.hfgw.com/DesktopDefault.aspx?tabindex=2&tabid=98 有没有代码可以参考!
...全文
109 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
vzxq 2004-08-13
  • 打赏
  • 举报
回复
if (!Page.IsPostBack)
{
//返回产品类型名称和类型ID
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConectionString"]);
SqlDataAdapter myCommand =new SqlDataAdapter("pro_type_name",conn);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
try
{
if (conn.State.ToString()=="Closed")
{
conn.Open();
}
//DataSet ds = new DataSet();
myCommand.Fill(ds,"ParentTable");
// DataView dv = new DataView(ds.Tables["ParentTable"]);
// dv.Sort = "pro_type_id desc";
// Data_pro_type.DataSource = dv;
Data_pro_type.DataSource=ds;
Data_pro_type.DataBind();
}
catch(Exception ex)
{
//Response.Redirect("Error_page.aspx?Error=invalid user!");
Response.Write(ex.Message);
}

finally
{
if (conn.State.ToString()=="Open")
{
conn.Close();
conn.Dispose();

}
}

//分类产品展示,返回 图片名,产品ID,产品编号,产品类型,产品名称

SqlConnection conn3 = new SqlConnection(ConfigurationSettings.AppSettings["ConectionString"]);
SqlDataAdapter myCommand3 =new SqlDataAdapter("img_list",conn3);
myCommand3.SelectCommand.CommandType = CommandType.StoredProcedure;

try
{
if (conn3.State.ToString()=="Closed")
{
conn3.Open();
}
//DataSet ds3 = new DataSet();
//myCommand3.Fill(ds3);
//DataList1.DataSource = ds3.Tables[0].DefaultView;
myCommand3.Fill(ds,"ChildTable");
//DataList1.DataBind();
//myCommand3.Dispose();
}
catch(Exception ex)
{
//Response.Redirect("Error_page.aspx?Error=invalid user!");
Response.Write(ex.Message);
}

finally
{
if (conn3.State.ToString()=="Open")
{
conn3.Close();
conn3.Dispose();
}
}

DataColumn Parent_Pro_type_id=ds.Tables["ParentTable"].Columns["Pro_type_id"];
DataColumn Child_Pro_type=ds.Tables["ChildTable"].Columns["Pro_type"];
ds.Relations.Add("ParentChild",Parent_Pro_type_id,Child_Pro_type);
DataList2.DataSource=ds.Tables["ParentTable"].DefaultView;
DataList2.DataBind();
gugh 2004-08-13
  • 打赏
  • 举报
回复
gz
gugh 2004-08-12
  • 打赏
  • 举报
回复
ding
gugh 2004-08-11
  • 打赏
  • 举报
回复
有没有具体的例子代码!
moodynight 2004-08-11
  • 打赏
  • 举报
回复
用DataList把 里面放两个控件 一个HyperLink 一个任意能放文本的控件 数据源为商品分类的列表 就是生鲜食品 粮油制品 这些东西 未HyperLin绑定上这些数据 然后在dataList的ItemDataBound里取出当前的分类(可以用e.Item.FindControl()来查到那个HyperLink,然后得到你绑定到上面的值) 根据查到的分类去数据库查到相关的商品 写进第二个控件就可以了
wagod 2004-08-11
  • 打赏
  • 举报
回复
不会

会的告诉我,谢谢

wagod@sohu.com

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧