I need to get to a status label I have on my footer section of my datalist.
There is no event happening that would go to the footer. I am just doing
some processing and want to update the label on the footer.
At the moment, I go through the dataListItems like so:
for each oItem as DataListItem in DataList1.Items
trace.warn("inside for loop oItem type = " &
oItem.itemType.ToString())
Dim oGrid as DataGrid =
CType(oItem.FindControl("DataGrid1"),DataGrid)
thePanel = CType(oItem.FindControl("dataListPanel"),Panel)
....
next
But the footer is not part of the dataListItems. If I have 8 rows,
datalist.items.count shows 8. This is without the footer. So going through
the list doesn't help me as I never see the footer.
Therefore, how do I get access to the Label that is on the footer?
Thanks
Tom 6 2169
Hi Tom,
Headers and footers are in the Controls collection, and not in the
Items colletion (as you've found out).
See "Finding Controls In Headers and Footers" in the following
article: http://odetocode.com/Articles/116.aspx
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 11:11:47 -0800, "tshad"
<ts**********@ftsolutions.com> wrote: I need to get to a status label I have on my footer section of my datalist.
There is no event happening that would go to the footer. I am just doing some processing and want to update the label on the footer.
At the moment, I go through the dataListItems like so:
for each oItem as DataListItem in DataList1.Items trace.warn("inside for loop oItem type = " & oItem.itemType.ToString()) Dim oGrid as DataGrid = CType(oItem.FindControl("DataGrid1"),DataGrid) thePanel = CType(oItem.FindControl("dataListPanel"),Panel) ... next
But the footer is not part of the dataListItems. If I have 8 rows, datalist.items.count shows 8. This is without the footer. So going through the list doesn't help me as I never see the footer.
Therefore, how do I get access to the Label that is on the footer?
Thanks
Tom
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:2d********************************@4ax.com... Hi Tom,
Headers and footers are in the Controls collection, and not in the Items colletion (as you've found out).
See "Finding Controls In Headers and Footers" in the following article: http://odetocode.com/Articles/116.aspx
The article was pretty good, but I can't seem to make it work.
Here is what I have:
The footer section:
************************************************** ****************************************
<FooterTemplate>
<SeparatorTemplate>
<hr style="margin:0">
</SeparatorTemplate>
<asp:Button ID="CollapseAll" visible=false text="Collapse All"
runat="server" onClick="collapseAll"/>;
<asp:Button ID="ExpandAll" visible=false text="Expand All"
runat="server" onClick="expandAll"/>;
<asp:Button ID="Submit" text=" Submit " runat="server"
onClick="submitSkillsTest"/>;
<asp:ImageButton ID="UpQuestion" text="Move Up" visible=true
runat="server" ImageUrl="../images/arrowLeft.gif"
style="height:16px;width:16px;" CommandName="Up"
OnClick="PreviousPage_Click" AlternateText="^"/>
<asp:ImageButton ID="DownQuestion" text="Move Down"
visible=true runat="server" ImageUrl="../images/arrowRight.gif"
style="height:16px;width:16px;" CommandName="Down" OnClick="NextPage_Click"
AlternateText="v"/>
<asp:Label ID="AnswerStatus" runat="server"/>
</FooterTemplate>
</asp:datalist>
************************************************** ******************************************
The code to find "AnswerStatus":
************************************************** ******************************************
Dim footerIndex as integer = DataList1.Controls(0).Controls.Count-1
trace.warn("footerIndex = " & footerIndex)
Dim AnswerStatus as Label =
CType(DataList1.Controls(0).Controls(footerIndex). FindControl("AnswerStatus"),Label)
if not AnswerStatus is nothing then
trace.warn("found the status label in the footer")
end if
************************************************** ******************************************
Part of the trace showing the above messages:
************************************************** ****************************************
inside Expandall 0.021046 0.014236
footerIndex = 2 0.021091 0.000044
inside for loop oItem type = Item 0.021137 0.000047
************************************************** ****************************************
As you can see the 2nd trace.warn is not showing.
Another part of the trace showing the footer:
************************************************** ************
DataList1:_ctl8
System.Web.UI.WebControls.DataListItem 780 0
DataList1:_ctl8:_ctl0 System.Web.UI.LiteralControl 101 0
DataList1:_ctl8: CollapseAll
System.Web.UI.WebControls.Button 0 0
DataList1:_ctl8:_ctl1 System.Web.UI.LiteralControl 22 0
DataList1:_ctl8:ExpandAll System.Web.UI.WebControls.Button 0 0
DataList1:_ctl8:_ctl2 System.Web.UI.LiteralControl 22 0
DataList1:_ctl8:Submit System.Web.UI.WebControls.Button 142
0
DataList1:_ctl8:_ctl3 System.Web.UI.LiteralControl 22 0
DataList1:_ctl8:UpQuestion System.Web.UI.WebControls.ImageButton
184 0
DataList1:_ctl8:_ctl4 System.Web.UI.LiteralControl 30 0
DataList1:_ctl8:DownQuestion System.Web.UI.WebControls.ImageButton 191
0
DataList1:_ctl8:_ctl5 System.Web.UI.LiteralControl 10 0
DataList1:_ctl8:AnswerStatus System.Web.UI.WebControls.Label 47 0
DataList1:_ctl8:_ctl6 System.Web.UI.LiteralControl 9 0
_ctl8
System.Web.UI.LiteralControl 8 0
************************************************** *************
As you can see "AnswerStatus" is there.
What am I missing?
Also, why would the FooterIndex be 2?
Thanks,
Tom -- Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 11:11:47 -0800, "tshad" <ts**********@ftsolutions.com> wrote:
I need to get to a status label I have on my footer section of my datalist.
There is no event happening that would go to the footer. I am just doing some processing and want to update the label on the footer.
At the moment, I go through the dataListItems like so:
for each oItem as DataListItem in DataList1.Items trace.warn("inside for loop oItem type = " & oItem.itemType.ToString()) Dim oGrid as DataGrid = CType(oItem.FindControl("DataGrid1"),DataGrid) thePanel = CType(oItem.FindControl("dataListPanel"),Panel) ... next
But the footer is not part of the dataListItems. If I have 8 rows, datalist.items.count shows 8. This is without the footer. So going through the list doesn't help me as I never see the footer.
Therefore, how do I get access to the Label that is on the footer?
Thanks
Tom
Also, here is part of the viewsource where the footer is:
************************************************** **********************************
</tr><tr>
<td align="Center">
<SeparatorTemplate>
<hr style="margin:0">
</SeparatorTemplate>
<input type="submit" name="DataList1:_ctl8:Submit" value=" Submit
" id="DataList1__ctl8_Submit" AlternateText="Click here to see details"
/>
<input type="image" name="DataList1:_ctl8:UpQuestion"
id="DataList1__ctl8_UpQuestion" text="Move Up" src="../images/arrowLeft.gif"
alt="^" border="0" style="height:16px;width:16px;" />
<input type="image" name="DataList1:_ctl8:DownQuestion"
id="DataList1__ctl8_DownQuestion" text="Move Down"
src="../images/arrowRight.gif" alt="v" border="0"
style="height:16px;width:16px;" />
<span id="DataList1__ctl8_AnswerStatus"></span>
</td>
</tr>
</table>
************************************************** *******************************
Thanks,
Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uj*************@TK2MSFTNGP15.phx.gbl... "Scott Allen" <sc***@nospam.odetocode.com> wrote in message news:2d********************************@4ax.com... Hi Tom,
Headers and footers are in the Controls collection, and not in the Items colletion (as you've found out).
See "Finding Controls In Headers and Footers" in the following article: http://odetocode.com/Articles/116.aspx
The article was pretty good, but I can't seem to make it work.
Here is what I have:
The footer section: ************************************************** **************************************** <FooterTemplate> <SeparatorTemplate> <hr style="margin:0"> </SeparatorTemplate> <asp:Button ID="CollapseAll" visible=false text="Collapse All" runat="server" onClick="collapseAll"/>; <asp:Button ID="ExpandAll" visible=false text="Expand All" runat="server" onClick="expandAll"/>; <asp:Button ID="Submit" text=" Submit " runat="server" onClick="submitSkillsTest"/>; <asp:ImageButton ID="UpQuestion" text="Move Up" visible=true runat="server" ImageUrl="../images/arrowLeft.gif" style="height:16px;width:16px;" CommandName="Up" OnClick="PreviousPage_Click" AlternateText="^"/> <asp:ImageButton ID="DownQuestion" text="Move Down" visible=true runat="server" ImageUrl="../images/arrowRight.gif" style="height:16px;width:16px;" CommandName="Down" OnClick="NextPage_Click" AlternateText="v"/> <asp:Label ID="AnswerStatus" runat="server"/> </FooterTemplate> </asp:datalist> ************************************************** ******************************************
The code to find "AnswerStatus":
************************************************** ****************************************** Dim footerIndex as integer = DataList1.Controls(0).Controls.Count-1 trace.warn("footerIndex = " & footerIndex) Dim AnswerStatus as Label = CType(DataList1.Controls(0).Controls(footerIndex). FindControl("AnswerStatus"),Label)
if not AnswerStatus is nothing then trace.warn("found the status label in the footer") end if ************************************************** ******************************************
Part of the trace showing the above messages: ************************************************** **************************************** inside Expandall 0.021046 0.014236 footerIndex = 2 0.021091 0.000044 inside for loop oItem type = Item 0.021137 0.000047 ************************************************** **************************************** As you can see the 2nd trace.warn is not showing.
Another part of the trace showing the footer: ************************************************** ************ DataList1:_ctl8 System.Web.UI.WebControls.DataListItem 780 0 DataList1:_ctl8:_ctl0 System.Web.UI.LiteralControl 101 0 DataList1:_ctl8: CollapseAll System.Web.UI.WebControls.Button 0 0 DataList1:_ctl8:_ctl1 System.Web.UI.LiteralControl 22 0 DataList1:_ctl8:ExpandAll System.Web.UI.WebControls.Button 0 0 DataList1:_ctl8:_ctl2 System.Web.UI.LiteralControl 22 0 DataList1:_ctl8:Submit System.Web.UI.WebControls.Button 142 0 DataList1:_ctl8:_ctl3 System.Web.UI.LiteralControl 22 0 DataList1:_ctl8:UpQuestion System.Web.UI.WebControls.ImageButton 184 0 DataList1:_ctl8:_ctl4 System.Web.UI.LiteralControl 30 0 DataList1:_ctl8:DownQuestion System.Web.UI.WebControls.ImageButton 191 0 DataList1:_ctl8:_ctl5 System.Web.UI.LiteralControl 10 0 DataList1:_ctl8:AnswerStatus System.Web.UI.WebControls.Label 47 0 DataList1:_ctl8:_ctl6 System.Web.UI.LiteralControl 9 0 _ctl8 System.Web.UI.LiteralControl 8 0 ************************************************** ************* As you can see "AnswerStatus" is there.
What am I missing?
Also, why would the FooterIndex be 2?
Thanks,
Tom
-- Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 11:11:47 -0800, "tshad" <ts**********@ftsolutions.com> wrote:
I need to get to a status label I have on my footer section of my datalist.
There is no event happening that would go to the footer. I am just doing some processing and want to update the label on the footer.
At the moment, I go through the dataListItems like so:
for each oItem as DataListItem in DataList1.Items trace.warn("inside for loop oItem type = " & oItem.itemType.ToString()) Dim oGrid as DataGrid = CType(oItem.FindControl("DataGrid1"),DataGrid ) thePanel = CType(oItem.FindControl("dataListPanel"),Panel) ... next
But the footer is not part of the dataListItems. If I have 8 rows, datalist.items.count shows 8. This is without the footer. So going through the list doesn't help me as I never see the footer.
Therefore, how do I get access to the Label that is on the footer?
Thanks
Tom
Me again.
Figured it out.
The dataGrid must have one more level of controls that the DataList. I put
a small set of code in my program to track the Controls (after seeing how
yours worked).
************************************************** **********************************
dim ktr1 as integer
dim ktr2 as integer
trace.warn("number of controls at top = " & DataList1.Controls.Count)
for ktr1 = 0 to DataList1.Controls.Count - 1
trace.warn("Control " & ktr1 & " = " &
DataList1.Controls(ktr1).getType().ToString() & " count = " &
DataList1.Controls(ktr1).controls.count)
for ktr2 = 0 to DataList1.Controls(ktr1).controls.count-1
trace.warn(" Control " & ktr2 & " = " &
DataList1.Controls(ktr1).Controls(ktr2).getType(). ToString() & " count = " &
DataList1.Controls(ktr1).Controls(ktr2).controls.c ount)
next
next
Dim footerIndex as integer = DataList1.Controls.Count-1
trace.warn("footerIndex = " & footerIndex)
Dim AnswerStatus as Label =
CType(DataList1.Controls(footerIndex).FindControl( "AnswerStatus"),Label)
************************************************** *******************************
I got the following results in my trace:
************************************************** *****************************
number of controls at top = 9
Control 0 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 2 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 3 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 4 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 5 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 6 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 7 = System.Web.UI.WebControls.DataListItem count = 3
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Panel count = 13
Control 2 = System.Web.UI.LiteralControl count = 0
Control 8 = System.Web.UI.WebControls.DataListItem count = 13
Control 0 = System.Web.UI.LiteralControl count = 0
Control 1 = System.Web.UI.WebControls.Button count = 0
Control 2 = System.Web.UI.LiteralControl count = 0
Control 3 = System.Web.UI.WebControls.Button count = 0
Control 4 = System.Web.UI.LiteralControl count = 0
Control 5 = System.Web.UI.WebControls.Button count = 0
Control 6 = System.Web.UI.LiteralControl count = 0
Control 7 = System.Web.UI.WebControls.ImageButton count = 0
Control 8 = System.Web.UI.LiteralControl count = 0
Control 9 = System.Web.UI.WebControls.ImageButton count = 0
Control 10 = System.Web.UI.LiteralControl count = 0
Control 11 = System.Web.UI.WebControls.Label count = 0
Control 12 = System.Web.UI.LiteralControl count = 0
footerIndex = 8
found the status label in the footer
************************************************** *******************************There is the "AnswerStatus" label 2nd to last in the list. An you can seethat the Find control is working fine now.I am curious about the LiteralControl that shows up after each control.Thanks,Tom"tshad" <ts**********@ftsolutions.com> wrote in messagenews:eO**************@TK2MSFTNGP14.phx.gbl. ..> Also, here is part of the viewsource where the footer is:>>********************************************* ***************************************> </tr><tr>> <td align="Center">> <SeparatorTemplate>>> <hr style="margin:0">> </SeparatorTemplate>> > > <input type="submit" name="DataList1:_ctl8:Submit" value=" Submit" id="DataList1__ctl8_Submit" AlternateText="Click here to see details"/> > <input type="image" name="DataList1:_ctl8:UpQuestion"id="DataList1__ct l8_UpQuestion" text="Move Up" src="../images/arrowLeft.gif"alt="^" border="0" style="height:16px;width:16px;" /> > <input type="image" name="DataList1:_ctl8:DownQuestion"id="DataList1__ ctl8_DownQuestion" text="Move Down"src="../images/arrowRight.gif" alt="v" border="0"style="height:16px;width:16px;" />> <span id="DataList1__ctl8_AnswerStatus"></span>> </td>>> </tr>> </table>>******************************************* **************************************>> Thanks,>> Tom> "tshad" <ts**********@ftsolutions.com> wrote in messagenews:uj*************@TK2MSFTNGP15.phx.gbl.. .>> "Scott Allen" <sc***@nospam.odetocode.com> wrote in messagenews:2d********************************@4ax .com...>>> Hi Tom,>>>>>> Headers and footers are in the Controls collection, and not in the>>> Items colletion (as you've found out).>>>>>> See "Finding Controls In Headers and Footers" in the following>>> article:>>> http://odetocode.com/Articles/116.aspx>>>> The article was pretty good, but I can't seem to make it work.>>>> Here is what I have:>>>> The footer section:>>**************************************** ************************************************** >> <FooterTemplate>>> <SeparatorTemplate>>> <hr style="margin:0">>> </SeparatorTemplate>>> <asp:Button ID="CollapseAll" visible=false text="Collapse All"runat="server" onClick="collapseAll"/>;>> <asp:Button ID="ExpandAll" visible=false text="Expand All"runat="server" onClick="expandAll"/>;>> <asp:Button ID="Submit" text=" Submit " runat="server"onClick="submitSkillsTest"/>;>> <asp:ImageButton ID="UpQuestion" text="Move Up" visible=truerunat="server" ImageUrl="../images/arrowLeft.gif"style="height:16px;width:16px;" CommandName="Up"OnClick="PreviousPage_Click" AlternateText="^"/> >> <asp:ImageButton ID="DownQuestion" text="Move Down"visible=true runat="server" ImageUrl="../images/arrowRight.gif"style="height:16px;width:16px;" CommandName="Down" OnClick="NextPage_Click"AlternateText="v"/>>> <asp:Label ID="AnswerStatus" runat="server"/>>> </FooterTemplate>>> </asp:datalist>>>*********************************** ************************************************** *******>>>> The code to find "AnswerStatus":>>>>******************************* ************************************************** ***********>> Dim footerIndex as integer = DataList1.Controls(0).Controls.Count-1>> trace.warn("footerIndex = " & footerIndex)>> Dim AnswerStatus as Label =CType(DataList1.Controls(0).Controls(footerIndex) .FindControl("AnswerStatus"),Label)>>>> if not AnswerStatus is nothing then>> trace.warn("found the status label in the footer")>> end if>>********************************************** **********************************************>>>> Part of the trace showing the above messages:>>*************************************** ************************************************** *>> inside Expandall 0.021046 0.014236>> footerIndex = 2 0.021091 0.000044>> inside for loop oItem type = Item 0.021137 0.000047>>**************************************** ************************************************** >> As you can see the 2nd trace.warn is not showing.>>>> Another part of the trace showing the footer:>> ************************************************** ************>> DataList1:_ctl8 System.Web.UI.WebControls.DataListItem 780 0>> DataList1:_ctl8:_ctl0 System.Web.UI.LiteralControl 1010>> DataList1:_ctl8: CollapseAllSystem.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl1 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:ExpandAll System.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl2 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:Submit System.Web.UI.WebControls.Button142 0>> DataList1:_ctl8:_ctl3 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:UpQuestion System.Web.UI.WebControls.ImageButton184 0>> DataList1:_ctl8:_ctl4 System.Web.UI.LiteralControl 300>> DataList1:_ctl8:DownQuestion System.Web.UI.WebControls.ImageButton191 0>> DataList1:_ctl8:_ctl5 System.Web.UI.LiteralControl 100>> DataList1:_ctl8:AnswerStatus System.Web.UI.WebControls.Label 47 0>> DataList1:_ctl8:_ctl6 System.Web.UI.LiteralControl 90>> _ctl8 System.Web.UI.LiteralControl 8 0>> ************************************************** *************>> As you can see "AnswerStatus" is there.>>>> What am I missing?>>>> Also, why would the FooterIndex be 2?>>>> Thanks,>>>> Tom>>>>>>>> -->>> Scott>>> http://www.OdeToCode.com/blogs/scott/>>>>>> On Thu, 10 Mar 2005 11:11:47 -0800, "tshad">>> <ts**********@ftsolutions.com> wrote:>>>>>>>I need to get to a status label I have on my footer section of mydatalist.>>>>>>>>There is no event happening that would go to the footer. I am justdoing>>>>some processing and want to update the label on the footer.>>>>>>>>At the moment, I go through the dataListItems like so:>>>>>>>> for each oItem as DataListItem in DataList1.Items>>>> trace.warn("inside for loop oItem type = " &>>>>oItem.itemType.ToString())>>>> Dim oGrid as DataGrid =>>>>CType(oItem.FindControl("DataGrid1"),DataGrid )>>>> thePanel = CType(oItem.FindControl("dataListPanel"),Panel)>>> >...>>>> next>>>>>>>>But the footer is not part of the dataListItems. If I have 8 rows,>>>>datalist.items.count shows 8. This is without the footer. So goingthrough>>>>the list doesn't help me as I never see the footer.>>>>>>>>Therefore, how do I get access to the Label that is on the footer?>>>>>>>>Thanks>>>>>>>>Tom>>>>>>>>>>>>>
Cool, glad you got it working!
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 15:38:00 -0800, "tshad"
<ts**********@ftsolutions.com> wrote: Me again.
Figured it out.
The dataGrid must have one more level of controls that the DataList. I put a small set of code in my program to track the Controls (after seeing how yours worked).
************************************************* *********************************** dim ktr1 as integer dim ktr2 as integer trace.warn("number of controls at top = " & DataList1.Controls.Count) for ktr1 = 0 to DataList1.Controls.Count - 1 trace.warn("Control " & ktr1 & " = " & DataList1.Controls(ktr1).getType().ToString() & " count = " & DataList1.Controls(ktr1).controls.count) for ktr2 = 0 to DataList1.Controls(ktr1).controls.count-1 trace.warn(" Control " & ktr2 & " = " & DataList1.Controls(ktr1).Controls(ktr2).getType() .ToString() & " count = " & DataList1.Controls(ktr1).Controls(ktr2).controls. count) next next
Dim footerIndex as integer = DataList1.Controls.Count-1 trace.warn("footerIndex = " & footerIndex) Dim AnswerStatus as Label = CType(DataList1.Controls(footerIndex).FindControl ("AnswerStatus"),Label) ************************************************* ********************************
I got the following results in my trace: ************************************************* ****************************** number of controls at top = 9 Control 0 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 2 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 3 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 4 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 5 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 6 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 7 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 8 = System.Web.UI.WebControls.DataListItem count = 13 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Button count = 0 Control 2 = System.Web.UI.LiteralControl count = 0 Control 3 = System.Web.UI.WebControls.Button count = 0 Control 4 = System.Web.UI.LiteralControl count = 0 Control 5 = System.Web.UI.WebControls.Button count = 0 Control 6 = System.Web.UI.LiteralControl count = 0 Control 7 = System.Web.UI.WebControls.ImageButton count = 0 Control 8 = System.Web.UI.LiteralControl count = 0 Control 9 = System.Web.UI.WebControls.ImageButton count = 0 Control 10 = System.Web.UI.LiteralControl count = 0 Control 11 = System.Web.UI.WebControls.Label count = 0 Control 12 = System.Web.UI.LiteralControl count = 0
footerIndex = 8 found the status label in the footer ************************************************** *******************************There is the "AnswerStatus" label 2nd to last in the list. An you can seethat the Find control is working fine now.I am curious about the LiteralControl that shows up after each control.Thanks,Tom"tshad" <ts**********@ftsolutions.com> wrote in messagenews:eO**************@TK2MSFTNGP14.phx.gbl. ..> Also, here is part of the viewsource where the footer is:>>********************************************* ***************************************> </tr><tr>> <td align="Center">> <SeparatorTemplate>>> <hr style="margin:0">> </SeparatorTemplate>> > > <input type="submit" name="DataList1:_ctl8:Submit" value=" Submit" id="DataList1__ctl8_Submit" AlternateText="Click here to see details"/> > <input type="image" name="DataList1:_ctl8:UpQuestion"id="DataList1__ct l8_UpQuestion" text="Move Up" src="../images/arrowLeft.gif"alt="^" border="0" style="height:16px;width:16px;" /> > <input type="image" name="DataList1:_ctl8:DownQuestion"id="DataList1__ ctl8_DownQuestion" text="Move Down"src="../images/arrowRight.gif" alt="v" border="0"style="height:16px;width:16px;" />> <span id="DataList1__ctl8_AnswerStatus"></span>> </td>>> </tr>> </table>>******************************************* **************************************>> Thanks,>> Tom> "tshad" <ts**********@ftsolutions.com> wrote in messagenews:uj*************@TK2MSFTNGP15.phx.gbl.. .>> "Scott Allen" <sc***@nospam.odetocode.com> wrote in messagenews:2d********************************@4ax .com...>>> Hi Tom,>>>>>> Headers and footers are in the Controls collection, and not in the>>> Items colletion (as you've found out).>>>>>> See "Finding Controls In Headers and Footers" in the following>>> article:>>> http://odetocode.com/Articles/116.aspx>>>> The article was pretty good, but I can't seem to make it work.>>>> Here is what I have:>>>> The footer section:>>**************************************** ************************************************** >> <FooterTemplate>>> <SeparatorTemplate>>> <hr style="margin:0">>> </SeparatorTemplate>>> <asp:Button ID="CollapseAll" visible=false text="Collapse All"runat="server" onClick="collapseAll"/>;>> <asp:Button ID="ExpandAll" visible=false text="Expand All"runat="server" onClick="expandAll"/>;>> <asp:Button ID="Submit" text=" Submit " runat="server"onClick="submitSkillsTest"/>;>> <asp:ImageButton ID="UpQuestion" text="Move Up" visible=truerunat="server" ImageUrl="../images/arrowLeft.gif"style="height:16px;width:16px;" CommandName="Up"OnClick="PreviousPage_Click" AlternateText="^"/> >> <asp:ImageButton ID="DownQuestion" text="Move Down"visible=true runat="server" ImageUrl="../images/arrowRight.gif"style="height:16px;width:16px;" CommandName="Down" OnClick="NextPage_Click"AlternateText="v"/>>> <asp:Label ID="AnswerStatus" runat="server"/>>> </FooterTemplate>>> </asp:datalist>>>*********************************** ************************************************** *******>>>> The code to find "AnswerStatus":>>>>******************************* ************************************************** ***********>> Dim footerIndex as integer = DataList1.Controls(0).Controls.Count-1>> trace.warn("footerIndex = " & footerIndex)>> Dim AnswerStatus as Label =CType(DataList1.Controls(0).Controls(footerIndex) .FindControl("AnswerStatus"),Label)>>>> if not AnswerStatus is nothing then>> trace.warn("found the status label in the footer")>> end if>>********************************************** **********************************************>>>> Part of the trace showing the above messages:>>*************************************** ************************************************** *>> inside Expandall 0.021046 0.014236>> footerIndex = 2 0.021091 0.000044>> inside for loop oItem type = Item 0.021137 0.000047>>**************************************** ************************************************** >> As you can see the 2nd trace.warn is not showing.>>>> Another part of the trace showing the footer:>> ************************************************** ************>> DataList1:_ctl8 System.Web.UI.WebControls.DataListItem 780 0>> DataList1:_ctl8:_ctl0 System.Web.UI.LiteralControl 1010>> DataList1:_ctl8: CollapseAllSystem.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl1 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:ExpandAll System.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl2 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:Submit System.Web.UI.WebControls.Button142 0>> DataList1:_ctl8:_ctl3 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:UpQuestion System.Web.UI.WebControls.ImageButton184 0>> DataList1:_ctl8:_ctl4 System.Web.UI.LiteralControl 300>> DataList1:_ctl8:DownQuestion System.Web.UI.WebControls.ImageButton191 0>> DataList1:_ctl8:_ctl5 System.Web.UI.LiteralControl 100>> DataList1:_ctl8:AnswerStatus System.Web.UI.WebControls.Label 47 0>> DataList1:_ctl8:_ctl6 System.Web.UI.LiteralControl 90>> _ctl8 System.Web.UI.LiteralControl 8 0>> ************************************************** *************>> As you can see "AnswerStatus" is there.>>>> What am I missing?>>>> Also, why would the FooterIndex be 2?>>>> Thanks,>>>> Tom>>>>>>>> -->>> Scott>>> http://www.OdeToCode.com/blogs/scott/>>>>>> On Thu, 10 Mar 2005 11:11:47 -0800, "tshad">>> <ts**********@ftsolutions.com> wrote:>>>>>>>I need to get to a status label I have on my footer section of mydatalist.>>>>>>>>There is no event happening that would go to the footer. I am justdoing>>>>some processing and want to update the label on the footer.>>>>>>>>At the moment, I go through the dataListItems like so:>>>>>>>> for each oItem as DataListItem in DataList1.Items>>>> trace.warn("inside for loop oItem type = " &>>>>oItem.itemType.ToString())>>>> Dim oGrid as DataGrid =>>>>CType(oItem.FindControl("DataGrid1"),DataGrid )>>>> thePanel = CType(oItem.FindControl("dataListPanel"),Panel)>>> >...>>>> next>>>>>>>>But the footer is not part of the dataListItems. If I have 8 rows,>>>>datalist.items.count shows 8. This is without the footer. So goingthrough>>>>the list doesn't help me as I never see the footer.>>>>>>>>Therefore, how do I get access to the Label that is on the footer?>>>>>>>>Thanks>>>>>>>>Tom>>>>>>>>>>>>>
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:ac********************************@4ax.com... Cool, glad you got it working!
Yes, it made a few things a little more clear, also.
Here is what I found out in my tests that might help someone else out.
Doing this I found that the DataGrid has one more set of controls than the
Datalist.
The dataGrid must have one more level of controls that the DataList. I put
a small set of code in my program to track the Controls (after seeing how
yours worked).
To get a control in a DataList Footer you would do the following:
Dim footerIndex as integer = DataList1.Controls.Count-1
Dim AnswerStatus as
Label=CType(DataList1.Controls(footerIndex).FindCo ntrol("AnswerStatus"),Label)
You could shorten it to:
CType(DataList1.Controls(DataList1.Controls.Count-1).FindControl("AnswerStatus"),Label)
To find it in the DataGrid (which has another level of controls) you would
do:
CType(DataGrid1.Control(0).Controls(DataList1.Cont rols.Count-1).FindControl("AnswerStatus"),Label)
To get a control in a DataList Header you would do the following:
CType(DataList1.Controls(0).FindControl("AnswerSta tus"),Label)
To find it in the DataGrid (which has another level of controls) you would
do:
CType(DataGrid1.Control(0).Controls(0).FindControl ("AnswerStatus"),Label)
I just don't know what the literal control that shows up after each control
is for, but it is important to know if you are looking throught the
controls. The Literal controls are always after the web controls (at least
there were in the traces I looked at) so your web controls are every other
control.
Tom -- Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Mar 2005 15:38:00 -0800, "tshad" <ts**********@ftsolutions.com> wrote:
Me again.
Figured it out.
The dataGrid must have one more level of controls that the DataList. I put a small set of code in my program to track the Controls (after seeing how yours worked).
************************************************ ************************************ dim ktr1 as integer dim ktr2 as integer trace.warn("number of controls at top = " & DataList1.Controls.Count) for ktr1 = 0 to DataList1.Controls.Count - 1 trace.warn("Control " & ktr1 & " = " & DataList1.Controls(ktr1).getType().ToString() & " count = " & DataList1.Controls(ktr1).controls.count) for ktr2 = 0 to DataList1.Controls(ktr1).controls.count-1 trace.warn(" Control " & ktr2 & " = " & DataList1.Controls(ktr1).Controls(ktr2).getType( ).ToString() & " count = " & DataList1.Controls(ktr1).Controls(ktr2).controls .count) next next
Dim footerIndex as integer = DataList1.Controls.Count-1 trace.warn("footerIndex = " & footerIndex) Dim AnswerStatus as Label = CType(DataList1.Controls(footerIndex).FindContro l("AnswerStatus"),Label) ************************************************ *********************************
I got the following results in my trace: ************************************************ ******************************* number of controls at top = 9 Control 0 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 2 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 3 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 4 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 5 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 6 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 7 = System.Web.UI.WebControls.DataListItem count = 3 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Panel count = 13 Control 2 = System.Web.UI.LiteralControl count = 0 Control 8 = System.Web.UI.WebControls.DataListItem count = 13 Control 0 = System.Web.UI.LiteralControl count = 0 Control 1 = System.Web.UI.WebControls.Button count = 0 Control 2 = System.Web.UI.LiteralControl count = 0 Control 3 = System.Web.UI.WebControls.Button count = 0 Control 4 = System.Web.UI.LiteralControl count = 0 Control 5 = System.Web.UI.WebControls.Button count = 0 Control 6 = System.Web.UI.LiteralControl count = 0 Control 7 = System.Web.UI.WebControls.ImageButton count = 0 Control 8 = System.Web.UI.LiteralControl count = 0 Control 9 = System.Web.UI.WebControls.ImageButton count = 0 Control 10 = System.Web.UI.LiteralControl count = 0 Control 11 = System.Web.UI.WebControls.Label count = 0 Control 12 = System.Web.UI.LiteralControl count = 0
footerIndex = 8 found the status label in the footer ************************************************** *******************************There is the "AnswerStatus" label 2nd to last in the list. An you can seethat the Find control is working fine now.I am curious about the LiteralControl that shows up after each control.Thanks,Tom"tshad" <ts**********@ftsolutions.com> wrote in messagenews:eO**************@TK2MSFTNGP14.phx.gbl. ..> Also, here is part of the viewsource where the footer is:>>********************************************* ***************************************> </tr><tr>> <td align="Center">> <SeparatorTemplate>>> <hr style="margin:0">> </SeparatorTemplate>> > > <input type="submit" name="DataList1:_ctl8:Submit" value=" Submit" id="DataList1__ctl8_Submit" AlternateText="Click here to see details"/> > <input type="image" name="DataList1:_ctl8:UpQuestion"id="DataList1__ct l8_UpQuestion" text="Move Up" src="../images/arrowLeft.gif"alt="^" border="0" style="height:16px;width:16px;" /> > <input type="image" name="DataList1:_ctl8:DownQuestion"id="DataList1 __ctl8_DownQuestion" text="Move Down"src="../images/arrowRight.gif" alt="v" border="0"style="height:16px;width:16px;" />> <span id="DataList1__ctl8_AnswerStatus"></span>> </td>>> </tr>> </table>>******************************************* **************************************>> Thanks,>> Tom> "tshad" <ts**********@ftsolutions.com> wrote in messagenews:uj*************@TK2MSFTNGP15.phx.gbl ...>> "Scott Allen" <sc***@nospam.odetocode.com> wrote in messagenews:2d********************************@4 ax.com...>>> Hi Tom,>>>>>> Headers and footers are in the Controls collection, and not in the>>> Items colletion (as you've found out).>>>>>> See "Finding Controls In Headers and Footers" in the following>>> article:>>> http://odetocode.com/Articles/116.aspx>>>> The article was pretty good, but I can't seem to make it work.>>>> Here is what I have:>>>> The footer section:>>************************************** ************************************************** **>> <FooterTemplate>>> <SeparatorTemplate>>> <hr style="margin:0">>> </SeparatorTemplate>>> <asp:Button ID="CollapseAll" visible=false text="Collapse All"runat="server" onClick="collapseAll"/>;>> <asp:Button ID="ExpandAll" visible=false text="Expand All"runat="server" onClick="expandAll"/>;>> <asp:Button ID="Submit" text=" Submit " runat="server"onClick="submitSkillsTest"/>;>> <asp:ImageButton ID="UpQuestion" text="Move Up" visible=truerunat="server" ImageUrl="../images/arrowLeft.gif"style="height:16px;width:16px;" CommandName="Up"OnClick="PreviousPage_Click" AlternateText="^"/> >> <asp:ImageButton ID="DownQuestion" text="Move Down"visible=true runat="server" ImageUrl="../images/arrowRight.gif"style="height:16px;width:16px;" CommandName="Down" OnClick="NextPage_Click"AlternateText="v"/>>> <asp:Label ID="AnswerStatus" runat="server"/>>> </FooterTemplate>>> </asp:datalist>>>*********************************** ************************************************** *******>>>> The code to find "AnswerStatus":>>>>***************************** ************************************************** *************>> Dim footerIndex as integer = DataList1.Controls(0).Controls.Count-1>> trace.warn("footerIndex = " & footerIndex)>> Dim AnswerStatus as Label =CType(DataList1.Controls(0).Controls(footerInde x).FindControl("AnswerStatus"),Label)>>>> if not AnswerStatus is nothing then>> trace.warn("found the status label in the footer")>> end if>>******************************************** ************************************************>> >> Part of the trace showing the above messages:>>************************************* ************************************************** ***>> inside Expandall 0.021046 0.014236>> footerIndex = 2 0.021091 0.000044>> inside for loop oItem type = Item 0.021137 0.000047>>************************************** ************************************************** **>> As you can see the 2nd trace.warn is not showing.>>>> Another part of the trace showing the footer:>> ************************************************ **************>> DataList1:_ctl8 System.Web.UI.WebControls.DataListItem 780 0>> DataList1:_ctl8:_ctl0 System.Web.UI.LiteralControl 1010>> DataList1:_ctl8: CollapseAllSystem.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl1 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:ExpandAll System.Web.UI.WebControls.Button 0 0>> DataList1:_ctl8:_ctl2 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:Submit System.Web.UI.WebControls.Button142 0>> DataList1:_ctl8:_ctl3 System.Web.UI.LiteralControl 220>> DataList1:_ctl8:UpQuestion System.Web.UI.WebControls.ImageButton184 0>> DataList1:_ctl8:_ctl4 System.Web.UI.LiteralControl 300>> DataList1:_ctl8:DownQuestion System.Web.UI.WebControls.ImageButton191 0>> DataList1:_ctl8:_ctl5 System.Web.UI.LiteralControl 100>> DataList1:_ctl8:AnswerStatus System.Web.UI.WebControls.Label 47 0>> DataList1:_ctl8:_ctl6 System.Web.UI.LiteralControl 90>> _ctl8 System.Web.UI.LiteralControl 8 0>> ************************************************ ***************>> As you can see "AnswerStatus" is there.>>>> What am I missing?>>>> Also, why would the FooterIndex be 2?>>>> Thanks,>>>> Tom>>>>>>>> -->>> Scott>>> http://www.OdeToCode.com/blogs/scott/>>>>>> On Thu, 10 Mar 2005 11:11:47 -0800, "tshad">>> <ts**********@ftsolutions.com> wrote:>>>>>>>I need to get to a status label I have on my footer section of mydatalist.>>>>>>>>There is no event happening that would go to the footer. I am justdoing>>>>some processing and want to update the label on the footer.>>>>>>>>At the moment, I go through the dataListItems like so:>>>>>>>> for each oItem as DataListItem in DataList1.Items>>>> trace.warn("inside for loop oItem type = " &>>>>oItem.itemType.ToString())>>>> Dim oGrid as DataGrid =>>>>CType(oItem.FindControl("DataGrid1"),DataGr id)>>>> thePanel = CType(oItem.FindControl("dataListPanel"),Panel)> >>>...>>>> next>>>>>>>>But the footer is not part of the dataListItems. If I have 8 rows,>>>>datalist.items.count shows 8. This is without the footer. So goingthrough>>>>the list doesn't help me as I never see the footer.>>>>>>>>Therefore, how do I get access to the Label that is on the footer?>>>>>>>>Thanks>>>>>>>>Tom>>>>>>>>>>>>> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kaung Htut O via DotNetMonster.com |
last post by:
Hi to all
Is there a way to access Datalist Footer's Control properties from outside
of datalist event. Pls note that I mean not a datagrid, only for datalist.
Thanks
Kaung Htut Oo
|
by: KathyB |
last post by:
Hi, sorry to be greedy with all my posts lately, but can you tell I'm
doing new things this week?
I've just done my first datalist (a simple one), that give me one
column of records. I would...
|
by: Paul Maidment |
last post by:
Hi,
I am a bit green when it comes to .net development so
please excuse me if this question is obvious or has been
asked before...
I am trying to programmatically access a label control...
|
by: mahsa |
last post by:
Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event?
--
Regards mahsa
|
by: Chris |
last post by:
Hi Folks,
well I have this "small" problem with the footertemplate in a
datalist.
I added a button and a textbox to update the db with the given String
of the Textbox.
I already searched for...
| |
by: Chris Fink |
last post by:
This should be relatively simple but I am unable to find an asp:button tag in
a datalist footer. I have tried it numerous ways including the FindControl
method from the many events that the...
|
by: tshad |
last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is
filled?
I have a bunch of DataGrids that get displayed nested inside a DataList.
The datagrid looks like:
...
|
by: amiga500 |
last post by:
Hello,
I have a DataList that displays the item information and total price
of each time but I want to add a footer with a complete subtotal. I am
using ASP.NET (VB) however I don't know how to...
|
by: Andy B |
last post by:
I have this code:
<asp:DataList id="NewsList" runat="server">
<HeaderTemplate>
News list
</HeaderTemplate>
<ItemTemplate>
<!-- news article code goes here -->
</ItemTemplate>...
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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...
|
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 ...
| |
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...
| |