472,783 Members | 984 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 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 3103
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,...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.