R
rote
I'm looping through a dataset below and adding some rows to my menuitems.
But what i want to achieve on this line
masterItem.Text = parentItem["Description"].ToString() + "[" +
masterItem.ChildItems.Count.ToString();+ "]";
is to get a count of the ChildRow and append it to the Text property below
For example the output should be:
--Nokia[68]
--Motorola[50]
But when i use masterItem.ChildItems.Count.ToString(); it just returns 0
Is this possible?
Code below
----------------------
DataSet ds =
getMasterDetail_Handset.getAllScheduleMaster_getHandSetsByPhoneCode(PhoneCode);
int hsRowCounts = ds.Tables["HandSets"].Rows.Count;if (hsRowCounts > 0)
{
Menu menu = new Menu();
foreach (DataRow parentItem in ds.Tables["MasterDetails"].Rows)
{
//MenuItem categoryItem = new MenuItem((string)parentItem["Master Code"]);
MenuItem masterItem = new MenuItem();
//categoryItem.ChildItems.Count.ToString();
masterItem.NavigateUrl = "#";
//masterItem.ChildItems.Count.ToString().ToString();
masterItem.Text = parentItem["Description"].ToString() + "[" +
parentItem["Dealer"].ToString() + "]";
menu.Items.Add(masterItem);
foreach (DataRow childItem in parentItem.GetChildRows("Children"))
{
MenuItem childrenItem = new
MenuItem((string)childItem["Description"]);childrenItem.NavigateUrl = "#";
masterItem.ChildItems.Add(childrenItem);
}
}
But what i want to achieve on this line
masterItem.Text = parentItem["Description"].ToString() + "[" +
masterItem.ChildItems.Count.ToString();+ "]";
is to get a count of the ChildRow and append it to the Text property below
For example the output should be:
--Nokia[68]
--Motorola[50]
But when i use masterItem.ChildItems.Count.ToString(); it just returns 0
Is this possible?
Code below
----------------------
DataSet ds =
getMasterDetail_Handset.getAllScheduleMaster_getHandSetsByPhoneCode(PhoneCode);
int hsRowCounts = ds.Tables["HandSets"].Rows.Count;if (hsRowCounts > 0)
{
Menu menu = new Menu();
foreach (DataRow parentItem in ds.Tables["MasterDetails"].Rows)
{
//MenuItem categoryItem = new MenuItem((string)parentItem["Master Code"]);
MenuItem masterItem = new MenuItem();
//categoryItem.ChildItems.Count.ToString();
masterItem.NavigateUrl = "#";
//masterItem.ChildItems.Count.ToString().ToString();
masterItem.Text = parentItem["Description"].ToString() + "[" +
parentItem["Dealer"].ToString() + "]";
menu.Items.Add(masterItem);
foreach (DataRow childItem in parentItem.GetChildRows("Children"))
{
MenuItem childrenItem = new
MenuItem((string)childItem["Description"]);childrenItem.NavigateUrl = "#";
masterItem.ChildItems.Add(childrenItem);
}
}