Hello Friends,
I have a child control nested within a parent control.
For example:
1>I used a details view control.
2>I wanted to customize the pager, so i did something like below:
<asp:DetailsView ID="dv" runat="server">
<PagerTemplate>
<asp:CheckBoxList ID="cbl" ToolTip="hi" runat="server" />
</PagerTemplate>
</asp:DetailsView>
Now i wanted to access the CheckBoxList in a button click's event handler. So in the event handler of the button, i did:
CheckBoxList cbl = (CheckBoxList)(dv.FindControl("cbl"));
here i applied a break point, i observed that "cbl" turned out to be "null".
I tried one more thing:
foreach (Control c in dv.Controls)
{
if (c is CheckBoxList)
{
Response.Write("true");
}
}
again i applied a break point on
Response.Write("true");
this is within the "if", it does not execute.
then i tried:
CheckBoxList cbl = (CheckBoxList)dv.BottomPagerRow.Cells[0].FindControl("cbl");
again "cbl" is null.
finally, i tried:
CheckBoxList cbl = (CheckBoxList)Page.FindControl("cbl");
"cbl" is null again.
I cant understand, why is that control "null"?
any suggestions?
Thanks and regards,
Rahul