473,382 Members | 1,639 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,382 software developers and data experts.

Problem finding child control within nested DataList!

The html below shows DataList "DiscountList" nested within DataList
"EventItemList". DiscountList contains a Label control.

I'm trying to find the label, using FindControl, during
EventList_ItemCreated (below the html), but it's always <undefined
value> (null). Everything else works fine. Eventually I need to set
the value of the label depending up the Count of the DataView
"dvDiscount". For now I'll settle for just finding the damn thing!

Anyone got any ideas about this?
Thanks everyone.
<asp:DataList runat="server" Id="EventItemList" RepeatColumns="1">
<HeaderTemplate>
<span class="BookingItemShortDesc">
The following booking options are available:<br>
</span>
<br>
</HeaderTemplate>
<ItemTemplate>
<span class=TinyLabel>Qty&nbsp;<asp:TextBox runat="server"
columns=5 width=30px height=18px
CssClass="TinyLabel"></asp:TextBox>&nbsp;</span>
<span class="BookingItemTitle" style="MARGIN-LEFT:5px;">
&nbsp;<%# DataBinder.Eval(Container, "DataItem.Description") %>
</span>
<asp:DataList runat="server" Id="DiscountList" RepeatColumns="3">
<HeaderTemplate>
<asp:Label id="Label1" runat="server"></asp:Label>
<span class="BookingItemShortDesc" style="MARGIN-LEFT:45px;">
The following discounts are available:<br>
</span>
</HeaderTemplate>
<ItemTemplate>
<span class="BookingItemShortDesc" style="MARGIN-LEFT:50px">
<span class=TinyLabel>Qty</span>
<%# DataBinder.Eval(Container.DataItem, "BandLow") %>
<span class=TinyLabel>to</span>
<%# DataBinder.Eval(Container.DataItem, "BandHigh") %>
<span class=TinyLabel>=</span>
<%# DataBinder.Eval(Container.DataItem, "DiscountRate") %>
<span class=TinyLabel>%</span>
</span>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
private void EventList_ItemCreated(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{

/************************** try to find the label *************/
Label lbl=((Label)e.Item.FindControl("Label1"));
if(lbl!=null)
lbl.Text="Label found";

if(e.Item.ItemType.ToString()=="Header")
{

}

if(e.Item.ItemType.ToString() == "Item" ||
e.Item.ItemType.ToString() ==
"AlternatingItem")
{
DataList dlTemp = ((DataList)e.Item.FindControl("DiscountList"));
int eventItemID = Convert.ToInt16(
((DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString());

dvDiscount.RowFilter="EventItemID=" +
Convert.ToString(eventItemID);

if(dvDiscount.Count > 0)
{
DiscountHeading="The following discounts apply:";
//this.DiscountLabel.Text="Discounts";
}
else
{
DiscountHeading="";
//this.DiscountLabel.Text="";
}
dlTemp.DataSource = dvDiscount;//dvDiscount.RowFilter=
dlTemp.DataBind();
}
}
Nov 18 '05 #1
1 3141
Try finding the embedded datalist first, then the label within the selected
item in that datalist.

"Doug" <go**************@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
The html below shows DataList "DiscountList" nested within DataList
"EventItemList". DiscountList contains a Label control.

I'm trying to find the label, using FindControl, during
EventList_ItemCreated (below the html), but it's always <undefined
value> (null). Everything else works fine. Eventually I need to set
the value of the label depending up the Count of the DataView
"dvDiscount". For now I'll settle for just finding the damn thing!

Anyone got any ideas about this?
Thanks everyone.
<asp:DataList runat="server" Id="EventItemList" RepeatColumns="1">
<HeaderTemplate>
<span class="BookingItemShortDesc">
The following booking options are available:<br>
</span>
<br>
</HeaderTemplate>
<ItemTemplate>
<span class=TinyLabel>Qty&nbsp;<asp:TextBox runat="server"
columns=5 width=30px height=18px
CssClass="TinyLabel"></asp:TextBox>&nbsp;</span>
<span class="BookingItemTitle" style="MARGIN-LEFT:5px;">
&nbsp;<%# DataBinder.Eval(Container, "DataItem.Description") %>
</span>
<asp:DataList runat="server" Id="DiscountList" RepeatColumns="3">
<HeaderTemplate>
<asp:Label id="Label1" runat="server"></asp:Label>
<span class="BookingItemShortDesc" style="MARGIN-LEFT:45px;">
The following discounts are available:<br>
</span>
</HeaderTemplate>
<ItemTemplate>
<span class="BookingItemShortDesc" style="MARGIN-LEFT:50px">
<span class=TinyLabel>Qty</span>
<%# DataBinder.Eval(Container.DataItem, "BandLow") %>
<span class=TinyLabel>to</span>
<%# DataBinder.Eval(Container.DataItem, "BandHigh") %>
<span class=TinyLabel>=</span>
<%# DataBinder.Eval(Container.DataItem, "DiscountRate") %>
<span class=TinyLabel>%</span>
</span>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
private void EventList_ItemCreated(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{

/************************** try to find the label *************/
Label lbl=((Label)e.Item.FindControl("Label1"));
if(lbl!=null)
lbl.Text="Label found";

if(e.Item.ItemType.ToString()=="Header")
{

}

if(e.Item.ItemType.ToString() == "Item" ||
e.Item.ItemType.ToString() ==
"AlternatingItem")
{
DataList dlTemp = ((DataList)e.Item.FindControl("DiscountList"));
int eventItemID = Convert.ToInt16(
((DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString());

dvDiscount.RowFilter="EventItemID=" +
Convert.ToString(eventItemID);

if(dvDiscount.Count > 0)
{
DiscountHeading="The following discounts apply:";
//this.DiscountLabel.Text="Discounts";
}
else
{
DiscountHeading="";
//this.DiscountLabel.Text="";
}
dlTemp.DataSource = dvDiscount;//dvDiscount.RowFilter=
dlTemp.DataBind();
}
}

Nov 18 '05 #2

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

Similar topics

1
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
2
by: CDWaddell | last post by:
I have the following cod private void btnUpdate_Click(object sender, System.EventArgs e TextBox tbMembers = new TextBox() tbMembers = (TextBox) dlClubs.FindControl("tbMembers") string...
0
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
2
by: Roman | last post by:
I have built a simple user control that contains 2 buttons, a text box and a dropdownlist. When a button is clicked it sets the visible property of the textbox/dropdownlist and the button. ie the...
0
by: s.gregory | last post by:
My page layout is like this: Page >DataList (databound using ObjectDataSource1 contained in page) >>Items >>>UserControl >>>>GridView (databound using another ObjectDataSource2 contained in...
0
by: ElGordo | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
by: nicklang | last post by:
Say you are creating a page which contains a child control which uses a DataList or DataGrid control. In a DataList, the rows are dynamic controls and are data bound, so you have to first load the...
5
by: Jim in Arizona | last post by:
How do I find a control within a datalist itemtemplate from a sub procedure that isn't a normal called procedure from a datalist (like the update, edit, or cancel procedures)? For instance,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.