473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem finding child control within nested DataList!

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

I'm trying to find the label, using FindControl, during
EventList_ItemC reated (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="EventItemLi st" RepeatColumns=" 1">
<HeaderTemplate >
<span class="BookingI temShortDesc">
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="TinyL abel"></asp:TextBox>&nb sp;</span>
<span class="BookingI temTitle" style="MARGIN-LEFT:5px;">
&nbsp;<%# DataBinder.Eval (Container, "DataItem.Descr iption") %>
</span>
<asp:DataList runat="server" Id="DiscountLis t" RepeatColumns=" 3">
<HeaderTemplate >
<asp:Label id="Label1" runat="server"> </asp:Label>
<span class="BookingI temShortDesc" style="MARGIN-LEFT:45px;">
The following discounts are available:<br>
</span>
</HeaderTemplate>
<ItemTemplate >
<span class="BookingI temShortDesc" style="MARGIN-LEFT:50px">
<span class=TinyLabel >Qty</span>
<%# DataBinder.Eval (Container.Data Item, "BandLow") %>
<span class=TinyLabel >to</span>
<%# DataBinder.Eval (Container.Data Item, "BandHigh") %>
<span class=TinyLabel >=</span>
<%# DataBinder.Eval (Container.Data Item, "DiscountRa te") %>
<span class=TinyLabel >%</span>
</span>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
private void EventList_ItemC reated(object sender,
System.Web.UI.W ebControls.Data ListItemEventAr gs e)
{

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

if(e.Item.ItemT ype.ToString()= ="Header")
{

}

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

dvDiscount.RowF ilter="EventIte mID=" +
Convert.ToStrin g(eventItemID);

if(dvDiscount.C ount > 0)
{
DiscountHeading ="The following discounts apply:";
//this.DiscountLa bel.Text="Disco unts";
}
else
{
DiscountHeading ="";
//this.DiscountLa bel.Text="";
}
dlTemp.DataSour ce = dvDiscount;//dvDiscount.RowF ilter=
dlTemp.DataBind ();
}
}
Nov 18 '05 #1
1 3157
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.goo gle.com...
The html below shows DataList "DiscountLi st" nested within DataList
"EventItemList" . DiscountList contains a Label control.

I'm trying to find the label, using FindControl, during
EventList_ItemC reated (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="EventItemLi st" RepeatColumns=" 1">
<HeaderTemplate >
<span class="BookingI temShortDesc">
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="TinyL abel"></asp:TextBox>&nb sp;</span>
<span class="BookingI temTitle" style="MARGIN-LEFT:5px;">
&nbsp;<%# DataBinder.Eval (Container, "DataItem.Descr iption") %>
</span>
<asp:DataList runat="server" Id="DiscountLis t" RepeatColumns=" 3">
<HeaderTemplate >
<asp:Label id="Label1" runat="server"> </asp:Label>
<span class="BookingI temShortDesc" style="MARGIN-LEFT:45px;">
The following discounts are available:<br>
</span>
</HeaderTemplate>
<ItemTemplate >
<span class="BookingI temShortDesc" style="MARGIN-LEFT:50px">
<span class=TinyLabel >Qty</span>
<%# DataBinder.Eval (Container.Data Item, "BandLow") %>
<span class=TinyLabel >to</span>
<%# DataBinder.Eval (Container.Data Item, "BandHigh") %>
<span class=TinyLabel >=</span>
<%# DataBinder.Eval (Container.Data Item, "DiscountRa te") %>
<span class=TinyLabel >%</span>
</span>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
private void EventList_ItemC reated(object sender,
System.Web.UI.W ebControls.Data ListItemEventAr gs e)
{

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

if(e.Item.ItemT ype.ToString()= ="Header")
{

}

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

dvDiscount.RowF ilter="EventIte mID=" +
Convert.ToStrin g(eventItemID);

if(dvDiscount.C ount > 0)
{
DiscountHeading ="The following discounts apply:";
//this.DiscountLa bel.Text="Disco unts";
}
else
{
DiscountHeading ="";
//this.DiscountLa bel.Text="";
}
dlTemp.DataSour ce = dvDiscount;//dvDiscount.RowF ilter=
dlTemp.DataBind ();
}
}

Nov 18 '05 #2

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

Similar topics

1
2057
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 buttons allow me to toggle between the textbox and the dropdownlist. This works fine when the control is placed on the page but when it is placed...
2
5192
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 sqlUpdate = "UPDATE tblClub SET "
0
460
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 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...
1
3332
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, asp:labels. Within the <form>, but outside the fieldset, containing the datatlist, I have a usercontrol (used to collect search criteria) and some...
2
2300
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 buttons allow me to toggle between the textbox and the dropdownlist. This works fine when the control is placed on the page but when it is placed...
0
1687
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 UserControl) So I've basically got a GridView (wrapped in a UserControl), that is nested within a DataList. Representing a fairly simple relational...
0
1152
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 OnEditCommand event is raised, I try to do the following: 1. Find the selected datalist item in which the nested datagrid raised the event. (by...
0
1043
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 data source and then DataBind. The problem arises when the containing Page calls DataBind before your child control, say in their Page_Load. So...
5
12885
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, normally you find a control and access it's properties and methods, like so: Sub Update(ByVal sender As Object, ByVal e As DataListCommandEventArgs) ...
0
7434
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.