trouble with FindControl

J

Jeff

hi

asp.net 2.0

I'm having trouble with findcontrol. The problem is in the code below. The
is that this line don't work:
label = (Label)e.Item.FindControl("lblKode");
label has a NULL value after that line is executed. I've checked and double
checked the spelling of the control name, it is named lblKode.

label = (Label)e.Item.FindControl("lblDesc"); works fine. that line I just
copied from the line above and changed lblKode to lblDesc, this line works
without any problem.. strange

protected void rptPhoneType_ItemDataBound(Object Sender,
RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
PhoneTypeDetail phonetype = (PhoneTypeDetail)e.Item.DataItem;
Label label;
label = (Label)e.Item.FindControl("lblKode");
label.Text = phonetype.Type.ToString();
label = (Label)e.Item.FindControl("lblDesc");
label.Text = phonetype.Desc;
}
}

here is markup of the Repeater
<asp:Repeater ID="rptPhoneType" runat="server"
OnItemDataBound="rptPhoneType_ItemDataBound">
<ItemTemplate>
<asp:Label ID="lblKode" runat="server"></asp:Label>
</ItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDesc" runat="server"></asp:Label>
</ItemTemplate>
</asp:Repeater>

any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top