mugsey
asked on
How to get reference to nested listview using findcontrol method
I have two listview controls nested
An outer listview and an inner listview
The innerlistview is a set of checkboxes that are populated from a database
I want code that uses the findcontrol method to get a reference to the inner listview so I can loop through all the checkboxes generated from the database and set them to false.
The markup for the controls is below
An outer listview and an inner listview
The innerlistview is a set of checkboxes that are populated from a database
I want code that uses the findcontrol method to get a reference to the inner listview so I can loop through all the checkboxes generated from the database and set them to false.
The markup for the controls is below
<asp:ListView ID="outerListView" runat="server" DataKeyNames="Id" OnItemDataBound="outerListView_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<fieldset>
<legend>
<%#Eval("Description") %></legend>
<!-- inner listview -->
<asp:ListView ID="innerListView" runat="server" DataKeyNames="Id" OnItemDataBound="innerListView_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<asp:CheckBox ID="_checkBoxField" runat="server" Text='<%#Eval("Description") %>'
OnCheckedChanged="_checkBoxField_CheckedChanged" />
<br />
</ItemTemplate>
</asp:ListView>
<!-- innerlistview -->
</fieldset>
</ItemTemplate>
</asp:ListView>
ASKER
OK thanks. However can I do the same thing you suggested but use the FINDCONTROLOFTYPE method?
As the html generated ID of each checkbox will be different.
As the html generated ID of each checkbox will be different.
hey,
Where did you got the method FINDCONTROLOFTYPE?
I have not used it before need to check that.
Sorry could not help you on this.
Thanks and regards,
Venki
Where did you got the method FINDCONTROLOFTYPE?
I have not used it before need to check that.
Sorry could not help you on this.
Thanks and regards,
Venki
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A reference to the parent listview is passed to the itemdatabound you can use it to find the child listview
protected void outerListView_DataBound(ob
{
ListView outerLstVw = (ListView)sender;
Listview innerLstVw = (ListView)outerLstVw.FindC
}
for more info you can also refer to the discussion here
http://forums.asp.net/t/1465507.aspx
I hope that this helps you
Thanks and regards,
Venki