Handling checkboxes in Repeater Control

Discussion in 'ASP .Net Web Controls' started by Imran Aziz, Aug 6, 2005.

  1. Imran Aziz

    Imran Aziz Guest

    Hello All,
    I have added html checkboxes in each row of the repeater control that I
    draw on the page. Now when I want to find out if the check boxes have been
    checked or not, I cannot seem to access them. Can anyone please guide me how
    to access child items in a repeater control.

    Here is my code.

    <ASP:Repeater id="lstOtherRepeater" runat="server" >

    <HeaderTemplate>

    <Table width="100%" >

    </HeaderTemplate>

    <ItemTemplate>

    <tr >

    <td>

    <input id="chkChannelID" type="checkbox" value="<%#
    DataBinder.Eval(Container.DataItem, "nChannelID") %>"/><a
    href="showitems.aspx?nChannelID=<%# DataBinder.Eval(Container.DataItem,
    "nChannelID") %>" ><%# DataBinder.Eval(Container.DataItem, "sChannelTitle")
    %></a>

    </td>

    </tr>

    <tr >

    <td>

    <%# DataBinder.Eval(Container.DataItem, "sChannelDescription")%>

    </td>

    </tr>

    </ItemTemplate>

    <FooterTemplate>

    </Table>

    </FooterTemplate>

    </ASP:Repeater>

    How can access the checkboxes in my code behind.

    Thanks a lot.


    Imran.
     
    Imran Aziz, Aug 6, 2005
    #1
    1. Advertising

  2. Imran Aziz

    Brock Allen Guest

    foreach(RepeaterItem i in lstOtherRepeater.Items)
    {
    HtmlInputCheckBox c = i.FindControl("chkChannelID") as HtmlInputCheckBox;
    if (c != null)
    {
    bool b = c.Checked;
    }
    }

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hello All,
    > I have added html checkboxes in each row of the repeater control
    > that I
    > draw on the page. Now when I want to find out if the check boxes have
    > been
    > checked or not, I cannot seem to access them. Can anyone please guide
    > me how to access child items in a repeater control.
    >
    > Here is my code.
    >
    > <ASP:Repeater id="lstOtherRepeater" runat="server" >
    >
    > <HeaderTemplate>
    >
    > <Table width="100%" >
    >
    > </HeaderTemplate>
    >
    > <ItemTemplate>
    >
    > <tr >
    >
    > <td>
    >
    > <input id="chkChannelID" type="checkbox" value="<%#
    > DataBinder.Eval(Container.DataItem, "nChannelID") %>"/><a
    > href="showitems.aspx?nChannelID=<%#
    > DataBinder.Eval(Container.DataItem, "nChannelID") %>" ><%#
    > DataBinder.Eval(Container.DataItem, "sChannelTitle") %></a>
    >
    > </td>
    >
    > </tr>
    >
    > <tr >
    >
    > <td>
    >
    > <%# DataBinder.Eval(Container.DataItem, "sChannelDescription")%>
    >
    > </td>
    >
    > </tr>
    >
    > </ItemTemplate>
    >
    > <FooterTemplate>
    >
    > </Table>
    >
    > </FooterTemplate>
    >
    > </ASP:Repeater>
    >
    > How can access the checkboxes in my code behind.
    >
    > Thanks a lot.
    >
    > Imran.
    >
     
    Brock Allen, Aug 7, 2005
    #2
    1. Advertising

  3. Imran Aziz

    Imran Aziz Guest

    thanks a lot Brock, that sorted out my problem :)
    Imran.
    "Brock Allen" <> wrote in message
    news:...
    > foreach(RepeaterItem i in lstOtherRepeater.Items)
    > {
    > HtmlInputCheckBox c = i.FindControl("chkChannelID") as
    > HtmlInputCheckBox;
    > if (c != null)
    > {
    > bool b = c.Checked;
    > }
    > }
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >> Hello All,
    >> I have added html checkboxes in each row of the repeater control
    >> that I
    >> draw on the page. Now when I want to find out if the check boxes have
    >> been
    >> checked or not, I cannot seem to access them. Can anyone please guide
    >> me how to access child items in a repeater control.
    >>
    >> Here is my code.
    >>
    >> <ASP:Repeater id="lstOtherRepeater" runat="server" >
    >>
    >> <HeaderTemplate>
    >>
    >> <Table width="100%" >
    >>
    >> </HeaderTemplate>
    >>
    >> <ItemTemplate>
    >>
    >> <tr >
    >>
    >> <td>
    >>
    >> <input id="chkChannelID" type="checkbox" value="<%#
    >> DataBinder.Eval(Container.DataItem, "nChannelID") %>"/><a
    >> href="showitems.aspx?nChannelID=<%#
    >> DataBinder.Eval(Container.DataItem, "nChannelID") %>" ><%#
    >> DataBinder.Eval(Container.DataItem, "sChannelTitle") %></a>
    >>
    >> </td>
    >>
    >> </tr>
    >>
    >> <tr >
    >>
    >> <td>
    >>
    >> <%# DataBinder.Eval(Container.DataItem, "sChannelDescription")%>
    >>
    >> </td>
    >>
    >> </tr>
    >>
    >> </ItemTemplate>
    >>
    >> <FooterTemplate>
    >>
    >> </Table>
    >>
    >> </FooterTemplate>
    >>
    >> </ASP:Repeater>
    >>
    >> How can access the checkboxes in my code behind.
    >>
    >> Thanks a lot.
    >>
    >> Imran.
    >>

    >
    >
    >
     
    Imran Aziz, Aug 8, 2005
    #3
    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. Mark
    Replies:
    3
    Views:
    3,243
    Steven Cheng[MSFT]
    Feb 3, 2004
  2. Ratman
    Replies:
    2
    Views:
    1,549
    Ratman
    Jul 4, 2004
  3. Imran Aziz

    Accessing Checkboxes in Repeater control

    Imran Aziz, Aug 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,013
    Imran Aziz
    Aug 8, 2005
  4. Per Salmi

    Repeater with Checkboxes, handling CheckedChanged event?

    Per Salmi, Feb 24, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,253
    Jeffrey Tan[MSFT]
    Feb 26, 2004
  5. Roshawn Dawson

    Repeater control and checkboxes

    Roshawn Dawson, Aug 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    145
    Roshawn Dawson
    Aug 17, 2005
Loading...

Share This Page