Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
810
WebDataMenu last Item disappear
posted

Hello~

I have a WebDataMenu1 in MasterPage, I give dynamic item with under code, but last item disappear, I must add a empty item, and last item (from datasoruce) will be appeare.
How can I fix it? thx.

Master.cs
protected void Page_Load(object sender, EventArgs e)
{
  SetMenu();
  // WebDataMenuMain.Items.Add(""); // when I add this line, the last item will can be appeare
}

private void SetMenu()
{
  DataTable dt = GetData(); // GetData result structure is a DataTable(Columns: ID, Name, ParentID)
  DataSet ds = new DataSet();
  ds.Tables.Add(dt);
  ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["ParentID"]);
  foreach (DataRow dr in dt.Rows)
  {
    if (dr["ParentID"] == DBNull.Value)
    {
      DataMenuItem newItem = new DataMenuItem();
      newItem.Text = dr["Name"].ToString().Trim();
      newItem.Key = dr["ID"].ToString().Trim();
      WebDataMenuMain.Items.Add(newItem);
    }
  }
}

Parents
No Data
Reply
  • 37874
    posted

    Hello Su Min,

    Your code seems to be correct. In order to be able to investigate this issue, I would need a running sample, reroducing this behavior. Thank you.

Children