473,320 Members | 2,020 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,320 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 8708
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.