ASP.NET AJAX MyAccordion Add 后只有最后一条数据!

来源:百度知道 编辑:UC知道 时间:2024/09/21 15:36:58
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conu = OpenCon())
{
string sql = "SELECT ID,CommodityListType FROM CommodityType order by ListGrade asc";
DataSet ds = new DataSet();
SqlDataAdapter data = new SqlDataAdapter(sql, conu);
data.Fill(ds, "dsew");
this.MyAccordion.DataSource = ds.Tables[0];
this.MyAccordion.DataBind();

if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
int u = 0;
Label lib1;
Label lib2;
foreach (DataRow dr in ds.Tables[0].Rows)
{
string title = Convert.ToString(dr["CommodityListType"]);
string typeID = Convert.ToString(dr["ID"]);

严重的逻辑错误

foreach (DataRow drs in dss.Tables[0].Rows)
{
string content = Convert.ToString(drs["ListName"]);
lib2.Text += content;
u++;
}

你这个循环完了lib2的值不就是最后一条么???
要想都加进去,就得在循环里面加。

楼主你代码太乱了
if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
int u = 0;//u和i不在一个级别 Label lib1;
Label lib2;
楼主通过单步调试观察MyAccordion.Panes的内容以及pin的变化,仔细找找原因,狂砍代码有点难找

你这个怎么是两重循环啊, 你到底要实现什么效果啊,那个Accordion就是实现一级的一个tab显示,
this.MyAccordion.DataSource = ds.Tables[0];
this.MyAccordion.DataBind();
这两行好像也没用