Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

i need to develop an accordian control with dynamic paging in asp.net.
I saw sample code in this site and implemented it:
http://yasserzaid.wordpress.com/2009/02/23/paging-dynamic-ajax-acordion-control/[^]

I am getting the data and binding the data to the header.

But when i click on the header, the control is not expanding.

PagedDataSource pds = new PagedDataSource();
  public int CurrentPage
  {
      get
      {
          if (this.ViewState["CurrentPage"] == null)
          {
              return 0;
          }
          else
          {
              return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
          }
      }
      set
      {
          this.ViewState["CurrentPage"] = value;
      }
  }
  private void doPaging()
  {
      DataTable dt = new DataTable();
      dt.Columns.Add("PageIndex");
      dt.Columns.Add("PageText");
      for (int i = 0; i < pds.PageCount; i++)
      {
          DataRow dr = dt.NewRow();
          dr[0] = i;
          dr[1] = i + 1;
          dt.Rows.Add(dr);
      }
      dlPaging.DataSource = dt;
      dlPaging.DataBind();
  }
  public void getCategories()
  {
      MySqlConnection sqlConn = new MySqlConnection("server=183.82.96.20;database=grid;uid=root;Pwd=pwd;");
      sqlConn.Open();
      MySqlCommand sqlSelect = new MySqlCommand("SELECT * FROM registrations", sqlConn);
      sqlSelect.CommandType = System.Data.CommandType.Text;
      MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(sqlSelect);
      DataTable dt = new DataTable();
      sqlAdapter.Fill(dt);
      pds.DataSource = dt.DefaultView;
      pds.AllowPaging = true;
      pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
      pds.CurrentPageIndex = CurrentPage;
      lnkbtnNext.Enabled = !pds.IsLastPage;
      lnkbtnPrevious.Enabled = !pds.IsFirstPage;
      Accordion1.DataSource = pds;
      Accordion1.DataBind();
      doPaging();
  }
  protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          getCategories();
      }
  }
  protected void Accordion1_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
  {
      if (e.ItemType == AjaxControlToolkit.AccordionItemType.Content)
      {
          MySqlConnection sqlConn = new MySqlConnection("server=183.82.96.20;database=grid;uid=root;Pwd=daf");
          MySqlCommand sqlSelect = new MySqlCommand("SELECT * FROM registrations where id = '" + ((HiddenField)e.AccordionItem.FindControl("txt_categoryID")).Value + "'", sqlConn);
          sqlSelect.CommandType = System.Data.CommandType.Text;
          MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(sqlSelect);
          DataSet myDataset = new DataSet();
          sqlAdapter.Fill(myDataset);

          GridView grd = new GridView();
          grd = (GridView)e.AccordionItem.FindControl("GridView1");
          grd.DataSource = myDataset;
          //GridView grd = new GridView();
          //grd = (GridView)e.AccordionItem.FindControl("GridView1");
          //grd.DataSource = myDataset;
          grd.DataBind();
      }
  }
  protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
  {
      if (e.CommandName.Equals("lnkbtnPaging"))
      {
          CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
          getCategories();
      }
  }
  protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
  {
      LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
      if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
      {
          lnkbtnPage.Enabled = false;
          lnkbtnPage.Font.Bold = true;
      }
  }
  protected void lnkbtnPrevious_Click(object sender, EventArgs e)
  {
      CurrentPage -= 1;
      getCategories();
  }
  protected void lnkbtnNext_Click(object sender, EventArgs e)
  {
      CurrentPage += 1;
      getCategories();
  }
  protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
  {
      CurrentPage = 0;
      getCategories();
  }


please can any body tell me what's wrong here?
Posted
Updated 19-Oct-11 20:45pm
v6
Comments
Reiss 19-Oct-11 9:24am    
Without your code, it is impossible to diagnose the problem, use the Improve Question widget to paste your code into the original question (only the relevant sections please, rather than a code dump)
[no name] 20-Oct-11 2:47am    
I had updated the question , please seee that questions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900