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

Find Button Control in DataList Footer

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 DataList exposes and the result is
always null (I've determined the OnItemDataBound event will not find the
footer controls). I understand that I have to navigate the datalist object
tree, but I feel like it is a guessing game and am hesitant to do it that way
since it will break when new controls are added to the datalist down the
road. Following is my aspx code:

<asp:datalist id="dlUnSelected" Runat="server" Width="880"
CssClass="DataListStyle">
<HeaderTemplate>
<tr bgColor="#3342b5">
<td class="zz" colspan="20" align="left" height="28"><b><font size="2"
color="#ffffff"><%# ProductID_Desc%> Rules: Available for
Selection</font></b></td>
</tr>
<tr vAlign="top" align=right bgColor="#d3d3d3">
<td class="dataheader" align="center" width="5" title="Row Number">#</td>
<td class="dataheader" align="center" width="5"></td>
<td class="dataheader" align="left" width="250" title="Rule
Description">RuleDesc</td>
<td class="dataheader" align="center" width="75" title="LookBack">LB</td>
<td class="dataheader" align="center" width="75" title="Guardian
Age">GA</td>
<td class="dataheader" align="center" width="250" title="Mail Age
Exclusion">Mail Age Exclusion</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Minimum">Age1</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Maximum">Age2</td>
<td class="dataheader" align="center" width="75" title="Rollup
Description">RollupDesc</td>
<td class="dataheader" align="center" width="100" title="Rollup
Minimum">RMN</td>
<td class="dataheader" align="center" width="100" title="Rollup
Maximum">RMX</td>
<td class="dataheader" align="center" width="75" title="Mail Limit">ML</td>
<td class="dataheader" align="center" width="75" title="Retail
Limit">RL</td>
<td class="dataheader" align="center" width="200" title="Rule
Exclusion">Rule Exclusion</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="trSelected" vAlign="center" align=right bgColor=#f5f5f5
runat="server">
<td class="data" align=left width="5"><%=CounterS%>.</td>
<td class="data" align=left width="5">
<asp:CheckBox ID="chkBox_U" AutoPostBack="False"
Runat="server"></asp:CheckBox>
<input NAME="ruleID_U" type="hidden" id="ruleID_U" value='<%#
DataBinder.Eval(Container.DataItem, "rule_id")%>' runat="server">
<input NAME="ruleDesc_U" type="hidden" id="ruleDesc_U" value='<%#
DataBinder.Eval(Container.DataItem, "description_rule_id")%>'
runat="server">
</td>
<td class="data" align="left" width="250" title="No Rule Description"><%#
(DataBinder.Eval(Container.DataItem,
"description_rule_id")).ToString().ToUpper()%> </td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtLB_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "lookback")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtGA_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "guardian_age")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="250">
<asp:DropDownList ID="ddlMailAgeVerbose_U" AutoPostBack="False"
Runat="server">
<asp:ListItem Selected Value="0">Select Range</asp:ListItem>
<asp:ListItem Value="1">If Under Age1:</asp:ListItem>
<asp:ListItem Value="2">If Over Age2:</asp:ListItem>
<asp:ListItem Value="3">If Between Age1 and Age2:</asp:ListItem>
<asp:ListItem Value="4">If Over Age1 or Under Age2:</asp:ListItem>
</asp:DropDownList>
</td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMIN_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMAX_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><%#
DataBinder.Eval(Container.DataItem, "rollup_description")%></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMIN_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMAX_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtML_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtRL_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "retail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="200">
<asp:DropDownList ID="ddlRuleExclusions_U"
Runat="server"></asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr vAlign="center" align=right bgColor="dcdcdc" height="28">
<td colspan="20" align="center"><asp:Button ID="btnSubmit_U"
OnClick="btnSubmit_U_Click" Text="Add Rules" CssClass="graygobtn"
Runat="server"></asp:Button></td>
</tr>
</FooterTemplate>
</asp:datalist>
Nov 18 '05 #1
2 8712
For the on item databound method:
Are you checking for the footer before using the find control method

I.E.:
void dlUnSelected_OnItemDataBound(object
source,DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
Button btn = (Button)e.Item.FindControl("btnSubmit");
}
}

"Chris Fink" <Ch*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
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 DataList exposes and the result is
always null (I've determined the OnItemDataBound event will not find the
footer controls). I understand that I have to navigate the datalist
object
tree, but I feel like it is a guessing game and am hesitant to do it that
way
since it will break when new controls are added to the datalist down the
road. Following is my aspx code:

<asp:datalist id="dlUnSelected" Runat="server" Width="880"
CssClass="DataListStyle">
<HeaderTemplate>
<tr bgColor="#3342b5">
<td class="zz" colspan="20" align="left" height="28"><b><font size="2"
color="#ffffff"><%# ProductID_Desc%> Rules: Available for
Selection</font></b></td>
</tr>
<tr vAlign="top" align=right bgColor="#d3d3d3">
<td class="dataheader" align="center" width="5" title="Row Number">#</td>
<td class="dataheader" align="center" width="5"></td>
<td class="dataheader" align="left" width="250" title="Rule
Description">RuleDesc</td>
<td class="dataheader" align="center" width="75" title="LookBack">LB</td>
<td class="dataheader" align="center" width="75" title="Guardian
Age">GA</td>
<td class="dataheader" align="center" width="250" title="Mail Age
Exclusion">Mail Age Exclusion</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Minimum">Age1</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Maximum">Age2</td>
<td class="dataheader" align="center" width="75" title="Rollup
Description">RollupDesc</td>
<td class="dataheader" align="center" width="100" title="Rollup
Minimum">RMN</td>
<td class="dataheader" align="center" width="100" title="Rollup
Maximum">RMX</td>
<td class="dataheader" align="center" width="75" title="Mail
Limit">ML</td>
<td class="dataheader" align="center" width="75" title="Retail
Limit">RL</td>
<td class="dataheader" align="center" width="200" title="Rule
Exclusion">Rule Exclusion</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="trSelected" vAlign="center" align=right bgColor=#f5f5f5
runat="server">
<td class="data" align=left width="5"><%=CounterS%>.</td>
<td class="data" align=left width="5">
<asp:CheckBox ID="chkBox_U" AutoPostBack="False"
Runat="server"></asp:CheckBox>
<input NAME="ruleID_U" type="hidden" id="ruleID_U" value='<%#
DataBinder.Eval(Container.DataItem, "rule_id")%>' runat="server">
<input NAME="ruleDesc_U" type="hidden" id="ruleDesc_U" value='<%#
DataBinder.Eval(Container.DataItem, "description_rule_id")%>'
runat="server">
</td>
<td class="data" align="left" width="250" title="No Rule Description"><%#
(DataBinder.Eval(Container.DataItem,
"description_rule_id")).ToString().ToUpper()%> </td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtLB_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "lookback")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtGA_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "guardian_age")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="250">
<asp:DropDownList ID="ddlMailAgeVerbose_U" AutoPostBack="False"
Runat="server">
<asp:ListItem Selected Value="0">Select Range</asp:ListItem>
<asp:ListItem Value="1">If Under Age1:</asp:ListItem>
<asp:ListItem Value="2">If Over Age2:</asp:ListItem>
<asp:ListItem Value="3">If Between Age1 and Age2:</asp:ListItem>
<asp:ListItem Value="4">If Over Age1 or Under Age2:</asp:ListItem>
</asp:DropDownList>
</td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMIN_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMAX_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><%#
DataBinder.Eval(Container.DataItem, "rollup_description")%></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMIN_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMAX_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtML_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtRL_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "retail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="200">
<asp:DropDownList ID="ddlRuleExclusions_U"
Runat="server"></asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr vAlign="center" align=right bgColor="dcdcdc" height="28">
<td colspan="20" align="center"><asp:Button ID="btnSubmit_U"
OnClick="btnSubmit_U_Click" Text="Add Rules" CssClass="graygobtn"
Runat="server"></asp:Button></td>
</tr>
</FooterTemplate>
</asp:datalist>

Nov 18 '05 #2
i think you should be alright using the ItemCreated event. The footer is not
accessible in ItemDataBound event handler.
for itemcreated try something like this

if(e.ItemType == ListItemType.Footer)
{
// a find control should be alright here
Button btnSubmit = e.FindControl("btnSubmit_U");

// whatever you need to do with the button here.
}

other way would be to iterate the Items collection of DataList

forearch(DataListItem dli in this.dlUnSelected.Items)
{
if(dli.ItemType == ListItemType.Footer)
{
// do a find control and whatever else needs to be done

}
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Chris Fink" <Ch*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
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 DataList exposes and the result is
always null (I've determined the OnItemDataBound event will not find the
footer controls). I understand that I have to navigate the datalist
object
tree, but I feel like it is a guessing game and am hesitant to do it that
way
since it will break when new controls are added to the datalist down the
road. Following is my aspx code:

<asp:datalist id="dlUnSelected" Runat="server" Width="880"
CssClass="DataListStyle">
<HeaderTemplate>
<tr bgColor="#3342b5">
<td class="zz" colspan="20" align="left" height="28"><b><font size="2"
color="#ffffff"><%# ProductID_Desc%> Rules: Available for
Selection</font></b></td>
</tr>
<tr vAlign="top" align=right bgColor="#d3d3d3">
<td class="dataheader" align="center" width="5" title="Row Number">#</td>
<td class="dataheader" align="center" width="5"></td>
<td class="dataheader" align="left" width="250" title="Rule
Description">RuleDesc</td>
<td class="dataheader" align="center" width="75" title="LookBack">LB</td>
<td class="dataheader" align="center" width="75" title="Guardian
Age">GA</td>
<td class="dataheader" align="center" width="250" title="Mail Age
Exclusion">Mail Age Exclusion</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Minimum">Age1</td>
<td class="dataheader" align="center" width="75" title="Mail Age
Maximum">Age2</td>
<td class="dataheader" align="center" width="75" title="Rollup
Description">RollupDesc</td>
<td class="dataheader" align="center" width="100" title="Rollup
Minimum">RMN</td>
<td class="dataheader" align="center" width="100" title="Rollup
Maximum">RMX</td>
<td class="dataheader" align="center" width="75" title="Mail
Limit">ML</td>
<td class="dataheader" align="center" width="75" title="Retail
Limit">RL</td>
<td class="dataheader" align="center" width="200" title="Rule
Exclusion">Rule Exclusion</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="trSelected" vAlign="center" align=right bgColor=#f5f5f5
runat="server">
<td class="data" align=left width="5"><%=CounterS%>.</td>
<td class="data" align=left width="5">
<asp:CheckBox ID="chkBox_U" AutoPostBack="False"
Runat="server"></asp:CheckBox>
<input NAME="ruleID_U" type="hidden" id="ruleID_U" value='<%#
DataBinder.Eval(Container.DataItem, "rule_id")%>' runat="server">
<input NAME="ruleDesc_U" type="hidden" id="ruleDesc_U" value='<%#
DataBinder.Eval(Container.DataItem, "description_rule_id")%>'
runat="server">
</td>
<td class="data" align="left" width="250" title="No Rule Description"><%#
(DataBinder.Eval(Container.DataItem,
"description_rule_id")).ToString().ToUpper()%> </td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtLB_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "lookback")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtGA_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "guardian_age")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="250">
<asp:DropDownList ID="ddlMailAgeVerbose_U" AutoPostBack="False"
Runat="server">
<asp:ListItem Selected Value="0">Select Range</asp:ListItem>
<asp:ListItem Value="1">If Under Age1:</asp:ListItem>
<asp:ListItem Value="2">If Over Age2:</asp:ListItem>
<asp:ListItem Value="3">If Between Age1 and Age2:</asp:ListItem>
<asp:ListItem Value="4">If Over Age1 or Under Age2:</asp:ListItem>
</asp:DropDownList>
</td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMIN_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtMAMAX_U"
Enabled="False" Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_age_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><%#
DataBinder.Eval(Container.DataItem, "rollup_description")%></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMIN_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_min")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="100"><asp:TextBox ID="txtRUMAX_U"
Width="30" style="text-align:right" Text='<%#
DataBinder.Eval(Container.DataItem, "rollup_max")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtML_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "mail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="75"><asp:TextBox ID="txtRL_U"
Width="30" style="text-align:right" Enabled="False" Text='<%#
DataBinder.Eval(Container.DataItem, "retail_limit")%>'
Runat="server"></asp:TextBox></td>
<td class="data" align="center" width="200">
<asp:DropDownList ID="ddlRuleExclusions_U"
Runat="server"></asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr vAlign="center" align=right bgColor="dcdcdc" height="28">
<td colspan="20" align="center"><asp:Button ID="btnSubmit_U"
OnClick="btnSubmit_U_Click" Text="Add Rules" CssClass="graygobtn"
Runat="server"></asp:Button></td>
</tr>
</FooterTemplate>
</asp:datalist>

Nov 18 '05 #3

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

Similar topics

4
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
1
by: David W. Simmonds | last post by:
I have a Button in a DataList Footer. I add the click event like this: void Item_DataBound(Object sender, DataListItemEventArgs e) { if(e.Item.ItemType == ListItemType.Footer) { Button ctlSave...
3
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
3
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...
9
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: ...
4
by: huzz | last post by:
I am trying to access a DropDownList control inside a repeater using ItemCommand as shown below but for some reason i can't access the DropDownList. When i step through the debug i get <undefine...
1
by: jagdishl | last post by:
Hi: I have a datalist which is populated dynamically based on a query.I have to place a submit button after datalist (not in the footer template) so that after pressing the submit button a final...
2
by: rhyme2ri2 | last post by:
Hi!! I'm using asp.net 1.1 I have a datalist which gets dynamic data which is of unbound size may be small sometimes and may be very very long sometimes....... Whatever the size of data may be...
1
by: Arielle | last post by:
Background: I have a generated datalist to display information and I need to add the capability to have a button (Edit button) so that users can change the information. I'm sure once I figure it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.