asp.net - How to add a <td> tag to ListViewItem? -
I want to apply the described application using nested list control. However, in my scenario, I can not use the EntityDataSource control, so I want to manually bind it.
My table:
Categories PK: UniqueId, Guid Name, String ParentId, Guid & lt; Asp: ListView id = "Class List" Run = "Server" onitemdatabound = "CategoryList_ItemDataBound" & gt; & Lt; LayoutTemplate & gt; & Lt; Table & gt; & Lt; ASP: Place Holder ID = "Item Place Holder" Runat = "Server" & gt; & Lt; / Asp: place holder & gt; & Lt; / Table & gt; & Lt; / LayoutTemplate & gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; Td colspan = "2" & gt; & Lt;% # Eval ("name")%> & Lt; / Td> & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: ListView & gt; Protected Zero Page_Load (Object Sender, EventAgages E) {Use (PracticesEntits Context = New PracticeEntities ()) {var results = from categories in reference Select categories categories; CategoryList.DataSource = Results; CategoryList.DataBind (); }} I want that item in the sub category to be a & lt; Td> Add an indent to an indent, which is not "ParentId" zero. And my question is how to edit the HTML tags generated in the ItemDataBound event?
You can do something like this:
& gt; Item Theme & gt; & Lt; TR & gt; & Lt; Td colspan = "2" & gt; & Lt;% # GetParentContent (Eval ("ParentID"))% & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / ItemTemplate & gt; Code-Back: Protected string GetParentContent (Object ParentID) {If (ParentID! = Null) ... back to original HTML ..
And then Return ""; }
Comments
Post a Comment