473,396 Members | 1,771 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.

access to control in footer template

Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event?
--
Regards mahsa
Nov 18 '05 #1
3 4416
Hi,

you can just declare the event handler for the CheckBox control in aspx
(inline in the footer template e.g into the declarative syntax) or another
way is to locate it in ItemCreated of the dataList and wire the event
handler programmatically. Both ways work equally.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"mahsa" <ma***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event? --
Regards mahsa

Nov 18 '05 #2
Hi,

like I said in my previous post, you must do it in *ItemCreated* (it is
different than ItemDataBound). ItemDataBound is not called for footer (only
for normal and alternating items according to the rows in data source), and
it is called only when DataBind is called for the DataList. You need to get
the code to run on every request, and ItemCreated works exactly that way and
additionally ItemCreated is called for the footer as well (DataListItem's
ItemType in ItemCreated is Footer then)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"mahsa" <ma***@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
hi I try this on DataList_ItemDataBound to find a control int footerIndex = DataList1.Controls[0].Controls.Count-1; CheckBox d;
d = DataList1.Controls[0].Controls[footerIndex].FindControl("Ch_LiftGround") as
CheckBox; if(d != null)
{
d.AutoPostBack=true;
d.CheckedChanged += new System.EventHandler(this.Ch_LiftGround_CheckedChan ged); }

but if the footer templete is not in item template like this:

<ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="Ch_LiftGround" Runat="server" Text="Lift Ground Service" class='caption' AutoPostBack=true ></asp:CheckBox> </FooterTemplate>
</ItemTemplate>
this code dosent work and if the footer is in daitemtemplate it dosent work exacty right either do you have any idea?


"Teemu Keiski" wrote:
Hi,

you can just declare the event handler for the CheckBox control in aspx
(inline in the footer template e.g into the declarative syntax) or another way is to locate it in ItemCreated of the dataList and wire the event
handler programmatically. Both ways work equally.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"mahsa" <ma***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,How can I access to checkbox control in footer template of datalist
and fire the selectedchangeindex event?
--
Regards mahsa


Nov 18 '05 #3
Hi I have this in DataList1_ItemDataCreate
CheckBox d;
int footerIndex = DataList1.Controls[0].Controls.Count-1;
d = DataList1.Controls[0].Controls[footerIndex].FindControl("Ch_LiftGround") as CheckBox;
if(d != null)
{
Response.Write("Found footer DropDownList1 in SelectedIndexChanged event<br>");
d.CheckedChanged += new System.EventHandler(this.Ch_LiftGround_CheckedChan ged);
}

but it dosent find check box do I have to put it in
I put it in (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
dosent find a control what can I do?it shows footerindex=0
whats your idea?

<FooterTemplate>
<tr> <td colspan=2 align=left width=100% runat=server ID="Td1" NAME="Td1">
<asp:CheckBox ID="Ch_LiftGround" Runat="server" AutoPostBack="True" Text="Lift Ground Service" class='caption' ></asp:CheckBox></td>
</tr>

"Teemu Keiski" wrote:
Hi,

like I said in my previous post, you must do it in *ItemCreated* (it is
different than ItemDataBound). ItemDataBound is not called for footer (only
for normal and alternating items according to the rows in data source), and
it is called only when DataBind is called for the DataList. You need to get
the code to run on every request, and ItemCreated works exactly that way and
additionally ItemCreated is called for the footer as well (DataListItem's
ItemType in ItemCreated is Footer then)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"mahsa" <ma***@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
hi I try this on DataList_ItemDataBound to find a control int footerIndex

= DataList1.Controls[0].Controls.Count-1;
CheckBox d;
d =

DataList1.Controls[0].Controls[footerIndex].FindControl("Ch_LiftGround") as
CheckBox;
if(d != null)
{
d.AutoPostBack=true;
d.CheckedChanged += new

System.EventHandler(this.Ch_LiftGround_CheckedChan ged);
}

but if the footer templete is not in item template like this:

<ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="Ch_LiftGround" Runat="server" Text="Lift Ground

Service" class='caption' AutoPostBack=true ></asp:CheckBox>
</FooterTemplate>
</ItemTemplate>
this code dosent work and if the footer is in daitemtemplate it dosent

work exacty right either do you have any idea?



"Teemu Keiski" wrote:
Hi,

you can just declare the event handler for the CheckBox control in aspx
(inline in the footer template e.g into the declarative syntax) or another way is to locate it in ItemCreated of the dataList and wire the event
handler programmatically. Both ways work equally.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"mahsa" <ma***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
> Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event?
> --
> Regards mahsa


Nov 18 '05 #4

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: 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...
5
by: Paul | last post by:
Hi I need to change the text value of a dropdown list box that is in a template column of a data grid but was not sure how to access it, probably something like datagrid1.control.dropdownlist.text...
4
by: sck10 | last post by:
Hello, I have a repeater that is bound to a SQL Server table. I would like to place a summary in the footer for the item count and product cost. I have two fields. One for the product name...
6
by: youvrajasnsm | last post by:
Hi, >I am working on ASP.net,using language . >I am using datagrid control and i filled it through datasource. >I have a column name Price and i want to sum price in Footer Template. >Can anybody...
2
by: pbeeke | last post by:
Can you prefill DataGrid footer template fieldswith items from the same datagrid. For example I am using the footer template in the grid in order to add a new record. THe query that updates the...
9
by: Adam Nielsen | last post by:
Hi all, I'm a bit confused about the syntax used to access a nested template class. Essentially I have a bunch of class types to represent different types of records in a database, and I want...
8
by: xz | last post by:
Why C++ (as well as Java) adopts class-based access control instead of instance-based access control? I had never paid attention to whether an access-control is class-based or instance-based but...
1
by: naasirsom | last post by:
Dear sir, I am using Gridview asp.net 2.0, I have a problem with Gridview Footer Template. I have put Button, Textbox and RequiredValidator in the Footer Template and Want to validate...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.