私は親子関係を持つオブジェクトを持っています。以下インデント付きの親/子孫名の表示
は私が持っているものの短いバージョンですが、以下のコアは、このような
public class Company
{
Name {get;set;}
List<Company> ChildCompany {get;set;}
}
表示何か小道具です:
-----ABC Corporation (in this chas ABC has child company so it will display right indent)
----------ABC Child
----------ABC One
----------ABC Two
-----BBC Corporation (in this case no child company)
-----CBS
-----CNN Corporation
----------ABC
----------BBC
----------NBC
私のコード:上記
Company company = new Company();
company = GetDataForCompany(); //DAL
if(!string.IsNullEmpty(company.Name))
{
//dispaly Name
PlaceHolder ph;
l = new Literal();
l.Text = "<ul>" + Environment.NewLine;
ph.Controls.Add(l);
l = new Literal();
l.Text = "<li">";
ph.Controls.Add(l);
hl = new HyperLink();
hl.Text = company.Name;
ph.Controls.Add(hl);
foreach (Company item in company)
{
l = new Literal();
l.Text = "<li">";
ph.Controls.Add(l);
hl = new HyperLink();
hl.Text = item.Name;
ph.Controls.Add(hl);
}
}
をコードは、上記のように私が望むものを正確に描画していないようです。
@AbuHamazahそれは何をレンダリングするのですか? –
レンダリングとは何ですか? – Jason
質問を編集して、予想されるマークアップと実際のマークアップを含めることはできますか? –