Question : could not find panel control in repeater

i have pnlanswer in repeater,
while finding pnlanswer in repeater,
it says 'object not set to instance.etc.'

Panel objPanel = (Panel)_repans.FindControl("pnlAnswer");
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
aspx
----
<td align="left" style="padding-left:15px;">
                                                <asp:Repeater ID="repAnswer" runat="server">
                                                <HeaderTemplate></HeaderTemplate>
                                                    <ItemTemplate>
                                                        <asp:Panel ID="pnlAnswer" CssClass="answercontent" runat="server">
                                                            <div style="float:left; margin-top:10px; margin-bottom:10px; padding-right:5px;">
                                                                <asp:CheckBox ID="chkAnswer" CssClass="checkboxLayout" runat="server" AutoPostBack="true"/>
                                                            </div> 

code-behind
-----------

protected void lbSubmit_Click(object sender, EventArgs e)
    {
        Boolean blnValid = false;
        //string strItemID = (sender as CheckBox).ClientID;

        Repeater _repans = (Repeater)repTopicExam.FindControl("repAnswer");

        Panel objPanel = (Panel)_repans.FindControl("pnlAnswer");

                if (objPanel.GetType().Name == "Panel")
                {
..

Answer : could not find panel control in repeater

ok man
now you have to make two for statement inside each other
for (int j= 0;j < repTopicExam .Items.Count; j++)
{
Repeater repAnswer= (Repeater)repTopicExam.items[j]..FindControl("repAnswer");

if(repAnswer !=null)
{
for (int i = 0; i < repAnswer.Items.Count; i++)
        {

            Panel objPanel = (Panel) repAnswer.Items[i].FindControl("pnlAnswer");

            if (objPanel.GetType().Name == "Panel")
            {
}

}}
Random Solutions  
 
programming4us programming4us