一个列表的问题? 不会会的告诉我,谢谢[email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用DataList把 里面放两个控件 一个HyperLink 一个任意能放文本的控件 数据源为商品分类的列表 就是生鲜食品 粮油制品 这些东西 未HyperLin绑定上这些数据 然后在dataList的ItemDataBound里取出当前的分类(可以用e.Item.FindControl()来查到那个HyperLink,然后得到你绑定到上面的值) 根据查到的分类去数据库查到相关的商品 写进第二个控件就可以了 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(); Arraylist 中的数据怎么排序? 关于web.config 50分求一个返回TOP 1数值的存储过程 如何解决这一问题? 页面中DataGrid 的Header 显示不正确问题 VS从2002升级到2003后发现水晶报表只能打开却无法编辑了 BLOB问题? 谁能帮我解决一下消息的问题 C#中怎么按任意键关闭MessageBox.Show()弹出的对话框! 我怎么新建一个工程都报错啊? 在datagrid中怎么用findcontrol? datagrid问题
{
//返回产品类型名称和类型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();