473,387 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

trouble with FindControl

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?
Oct 29 '08 #1
2 1497
Is this normal you have two ItemTemplate in your repeater ?

Else my approach would be to just dump the content. For now I would say the
second template overrides the first template...

--
Patrice

"Jeff" <it************@hotmail.com.NOSPAMa écrit dans le message de groupe
de discussion : OD**************@TK2MSFTNGP05.phx.gbl...
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?
Oct 29 '08 #2
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OD**************@TK2MSFTNGP05.phx.gbl...
Any suggestions?
Patrice is correct. You can't have more than one <ItemTemplate /in an
<asp:Repeater />

Well, you can, but all except the final one will be ignored...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: James G. Beldock | last post by:
I have seen the following behavior: when issuing a Page.FindControl() for a control which exists in an item template (from within an ItemDataBound() event, for example), I get nulls back...
0
by: 2obvious | last post by:
I have a DataGrid containing a TextBox control and a CustomValidator in each row. The CustomValidator fires a function that compares all TextBoxes for equality. The algorithm for comparison...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
1
by: Krish | last post by:
Hello Gurus, I have GridView control on web page which has couple of radio button controls as one group. On editing a particular row in grid, i have to validate based on user selection on radio...
14
by: aroraamit81 | last post by:
Hi, I am facing a trouble. I have some Session variables in my code and somehow my session variables are getting mixed up with other users. For example User A has access to 10 companies and...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
7
by: AAaron123 | last post by:
Me.FindControl("MissionScheduleID"), below returns null. Do you know what I'm doing wrong? Thanks ***In my .aspx file I have: asp:Content ID="Content3"...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
4
by: Hillbilly | last post by:
Maybe this is or isn't some kind of bug but it sure is goofy and remains a mystery that really has me puzzled for two reasons... // goofy syntax functions as expected... Panel finalStepButton =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.