Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to use find control
bcoz
i have a datalist view ane
there is two label

first consist some values
and i want to use of that value and doing some operation on that value
and display it in another label
so, give me a proper solution with EXAMPLE....
XML
<asp:DataList ID="DataList1" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text="11:10:00" ></asp:Label>
            <asp:Label ID="Label2" runat="server"></asp:Label>
        </ItemTemplate>
        </asp:DataList>

for the purpose of auction site,

i use it
in Label1 ,i displayed close time
now i want to put countdown timer in second label.
so i used Label1 time and server time and subtract it and subtracted result i want to display in Label2....
Posted
Updated 9-Jan-12 4:06am
v2
Comments
Suraj S Koneri 9-Jan-12 9:25am    
Please correct the requirement, its not understandable. On what event you need to perform operation on that and what that label contains
PKriyshnA 9-Jan-12 9:29am    
for the purpose of auction site,

i use it
in Label1 ,i displayed close time
now i want to put countdown timer in second label.
so i used Label1 time and server time and subtract it and subtracted result i want to display in Label2....

1 solution

You're probably trying to call FindControl on the DataList itself.
That is not possible because there is no item of type Label with the given ID. Instead there are a lot of templated DataList items each containing 2 labels with the IDs "Label1" and "Label2". Due to that you have to call FindControl on the DataList's items.

C#
foreach( var item in DataList1.Items )
{
    Label label1 = (Label)item.FindControl( "Label1" );
    ...
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900