不会会的告诉我,谢谢[email protected]

解决方案 »

  1.   

    用DataList把 里面放两个控件 一个HyperLink 一个任意能放文本的控件 数据源为商品分类的列表 就是生鲜食品 粮油制品 这些东西 未HyperLin绑定上这些数据 然后在dataList的ItemDataBound里取出当前的分类(可以用e.Item.FindControl()来查到那个HyperLink,然后得到你绑定到上面的值) 根据查到的分类去数据库查到相关的商品 写进第二个控件就可以了
      

  2.   

    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();