Note that there are some explanatory texts on larger screens.

plurals
  1. POControls.Remove() does not work after CreateChildControls?
    primarykey
    data
    text
    <p>I am developing a SharePoint 2010 non-visual WebPart which displays some kind of data in a big table. The table rows should be filtered by selecting a filter criterium from a DropDownList which is part of the webpart.</p> <p>The OnSelectedIndexChanged event of the DropDownList is fired after CreateChildControls and before OnPreRender. Because the cells of the table contain LinkButtons with an OnClick event attached, they must be created in CreateChildControls in order to get the OnClick events fired.</p> <p>I don't know which rows of the table to hide until the OnSelectedIndexChanged of the DropDownList is fired, so I create all possible table rows in CreateChldControls and try to remove the filtered ones later in OnSelectedIndexChanged the event directly or in OnPreRender. The rows were physically removed from the parent Table's control collection, but they are nevertheles displayed. </p> <p>As a test, I tried to remove some random rows at the end of the CreateChildControls method after creating them, it worked and the rows were not rendered.</p> <p>How I remove the rows: </p> <pre><code> Table mt = FindControl("matrixtable") as Table; Helpers.Log("Controls in Table: " + mt.Controls.Count); foreach (int kdid in kdIdsInvisible) { TableRow c = mt.FindControl("kdrow" + kdid) as TableRow; Helpers.Log(c.ID); mt.Controls.Remove(c); } Helpers.Log("Controls in Table: " + mt.Controls.Count); </code></pre> <p>Output:</p> <pre><code>Controls in Table: 88 Controls in Table: 2 </code></pre> <p>But all rows are still rendered...</p> <p>Is there a solution for this? Thank you in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload