access to control in footer template

Discussion in 'ASP .Net' started by =?Utf-8?B?bWFoc2E=?=, Jul 9, 2004.

  1. Hi,How can I access to checkbox control in footer template of datalist and fire the selectedchangeindex event?
    --
    Regards mahsa
     
    =?Utf-8?B?bWFoc2E=?=, Jul 9, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?bWFoc2E=?=

    Teemu Keiski Guest

    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" <> wrote in message
    news:...
    > Hi,How can I access to checkbox control in footer template of datalist and

    fire the selectedchangeindex event?
    > --
    > Regards mahsa
     
    Teemu Keiski, Jul 9, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?bWFoc2E=?=

    Teemu Keiski Guest

    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" <> wrote in message
    news:...
    > 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_CheckedChanged);
    > }
    >
    > 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" <> wrote in message
    > > news:...
    > > > Hi,How can I access to checkbox control in footer template of datalist

    and
    > > fire the selectedchangeindex event?
    > > > --
    > > > Regards mahsa

    > >
    > >
    > >
     
    Teemu Keiski, Jul 9, 2004
    #3
  4. 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_CheckedChanged);
    }

    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" <> wrote in message
    > news:...
    > > 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_CheckedChanged);
    > > }
    > >
    > > 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" <> wrote in message
    > > > news:...
    > > > > Hi,How can I access to checkbox control in footer template of datalist

    > and
    > > > fire the selectedchangeindex event?
    > > > > --
    > > > > Regards mahsa
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?bWFoc2E=?=, Jul 10, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Maidment
    Replies:
    1
    Views:
    4,403
    Nick Berardi
    Aug 7, 2003
  2. John Crowley
    Replies:
    2
    Views:
    486
    =?Utf-8?B?Sm9obiBDcm93bGV5?=
    Feb 6, 2004
  3. George

    Access to controls in footer template

    George, May 11, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    230
    Leonardo Rodríguez
    May 12, 2004
  4. Replies:
    1
    Views:
    308
  5. Henrik
    Replies:
    1
    Views:
    434
    Ken Cox [Microsoft MVP]
    Jul 6, 2006
Loading...

Share This Page