Nested Datalist Controls

Discussion in 'ASP .Net Datagrid Control' started by Darrin, Dec 28, 2005.

  1. Darrin

    Darrin Guest

    Greetings, I am trying to get the checkbox value from a nested datalist once
    I press a button on my form (not within any of the datalist grids). I am
    using asp.net 1.1/vb.net

    The project I am working on provides users to register for a specific event
    and also view all the sessions going on for that event. See example below.


    Event: Microsoft Office Training
    Location: My City
    Date: Dec 21st

    Available Sessions:
    Wednesday Dec 21st, 9:00AM
    *Word 101 (checkbox)
    *Excel 200 (checkbox)
    *Access (checkbox)

    Wednesday Dec 21st 2:00PM
    *Access 200 (checkbox)
    *Powerpoint (checkbox)

    The first datalist (dlSessionDatesTimes) I created goes out to my SQL table
    to group the sessions by date and time for the particular event. As the
    dlSessionDatesTimes datalist is generated, I go out to my SQL table and
    gather all the realted sessions for that particular event, date and time.
    These are displayed in the second datalist (dlSessions). Next to each
    session I have a check box so the user can go through and select the session
    they wish to sign up for.

    The question:
    After I click the submit button on my form I want to caputure the values
    from the check box. How do I access the checkbox that is nested inside the
    other datalist (dlSessions)? Or is there another way?

    <asp:datalist id="dlSessionDatesTimes" runat="server"
    CellSpacing="15" CellPadding="5" Width="100%"
    RepeatColumns="1">
    <ItemTemplate>
    <TABLE class="Content" id="Table3" cellSpacing="1"
    cellPadding="5" width="100%" border="0">
    <TR>
    <TD
    class="Normal"><B><%#FormatDateTime(DataBinder.Eval(Container.DataItem,
    "WS_DATE"),1) & "-" & Format(DataBinder.Eval(Container.DataItem,
    "WS_StartTime"),"Short Time")%></B></TD>
    </TR>
    <TR>
    <TD></TD>
    </TR>
    <TR>
    <TD></TD>
    </TR>
    </TABLE>
    <asp:DataList id=dlSessions runat="server" CssClass="normal"
    DataSource='<%# ListSessions(DataBinder.Eval(Container.DataItem,
    "WS_DATE"),DataBinder.Eval(Container.DataItem, "WS_StartTime")) %>'
    RepeatLayout="Flow">
    <ItemTemplate>
    <table class="Normal">
    <tr>
    <td>
    Description:</td>
    <td><%# Container.DataItem("WS_Description")%></td>
    </tr>
    <tr>
    <td>Presenter:</td>
    <td><%# Container.DataItem("WS_Presenter")%></td>
    </tr>
    <tr>
    <td>Target Audience:</td>
    <td><%# Container.DataItem("WS_TargetAudience")%></td>
    </tr>
    <tr>
    <td>Location Area:</td>
    <td><%# Container.DataItem("WS_LocationArea")%></td>
    </tr>
    <tr>
    <td>CEUS Offered:</td>
    <td><%# Container.DataItem("WS_CEUSOFfered")%></td>
    </tr>
    <tr>
    <td>
    <asp:checkbox id="chkCEUs" runat="server" Text="CEU's
    Offered">
    </asp:checkbox></td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:DataList>
    </ItemTemplate>
    </asp:datalist></TD>
    </TR>
    <TR>
    <TD>
    <asp:Button id="Button1" runat="server"
    Text="Button"></asp:Button></TD>
    </TR>
    <TR>
    <TD></TD>
    </TR>
    </TABLE>
    Darrin, Dec 28, 2005
    #1
    1. Advertising

  2. Darrin

    Elton Wang Guest

    Hi Darrin,



    Following code shows how to loop thru to get

    checkbox in the inner datalist:



    Dim innerList As DataList
    Dim ckBox As CheckBox
    For Each item As DataListItem In dlSessionDatesTimes.Items

    innerList = CType(item.FindControl("dlSessions"), DataList)
    For Each innerItem As DataListItem In innerList.Items
    ckBox = CType(innerList.FindControl("chkCEUs"), CheckBox)
    ' process

    Next
    Next



    HTH





    "Darrin" <> wrote in message
    news:...
    > Greetings, I am trying to get the checkbox value from a nested datalist
    > once
    > I press a button on my form (not within any of the datalist grids). I am
    > using asp.net 1.1/vb.net
    >
    > The project I am working on provides users to register for a specific
    > event
    > and also view all the sessions going on for that event. See example
    > below.
    >
    >
    > Event: Microsoft Office Training
    > Location: My City
    > Date: Dec 21st
    >
    > Available Sessions:
    > Wednesday Dec 21st, 9:00AM
    > *Word 101 (checkbox)
    > *Excel 200 (checkbox)
    > *Access (checkbox)
    >
    > Wednesday Dec 21st 2:00PM
    > *Access 200 (checkbox)
    > *Powerpoint (checkbox)
    >
    > The first datalist (dlSessionDatesTimes) I created goes out to my SQL
    > table
    > to group the sessions by date and time for the particular event. As the
    > dlSessionDatesTimes datalist is generated, I go out to my SQL table and
    > gather all the realted sessions for that particular event, date and time.
    > These are displayed in the second datalist (dlSessions). Next to each
    > session I have a check box so the user can go through and select the
    > session
    > they wish to sign up for.
    >
    > The question:
    > After I click the submit button on my form I want to caputure the values
    > from the check box. How do I access the checkbox that is nested inside
    > the
    > other datalist (dlSessions)? Or is there another way?
    >
    > <asp:datalist id="dlSessionDatesTimes" runat="server"
    > CellSpacing="15" CellPadding="5" Width="100%"
    > RepeatColumns="1">
    > <ItemTemplate>
    > <TABLE class="Content" id="Table3" cellSpacing="1"
    > cellPadding="5" width="100%" border="0">
    > <TR>
    > <TD
    > class="Normal"><B><%#FormatDateTime(DataBinder.Eval(Container.DataItem,
    > "WS_DATE"),1) & "-" & Format(DataBinder.Eval(Container.DataItem,
    > "WS_StartTime"),"Short Time")%></B></TD>
    > </TR>
    > <TR>
    > <TD></TD>
    > </TR>
    > <TR>
    > <TD></TD>
    > </TR>
    > </TABLE>
    > <asp:DataList id=dlSessions runat="server" CssClass="normal"
    > DataSource='<%# ListSessions(DataBinder.Eval(Container.DataItem,
    > "WS_DATE"),DataBinder.Eval(Container.DataItem, "WS_StartTime")) %>'
    > RepeatLayout="Flow">
    > <ItemTemplate>
    > <table class="Normal">
    > <tr>
    > <td>
    > Description:</td>
    > <td><%# Container.DataItem("WS_Description")%></td>
    > </tr>
    > <tr>
    > <td>Presenter:</td>
    > <td><%# Container.DataItem("WS_Presenter")%></td>
    > </tr>
    > <tr>
    > <td>Target Audience:</td>
    > <td><%# Container.DataItem("WS_TargetAudience")%></td>
    > </tr>
    > <tr>
    > <td>Location Area:</td>
    > <td><%# Container.DataItem("WS_LocationArea")%></td>
    > </tr>
    > <tr>
    > <td>CEUS Offered:</td>
    > <td><%# Container.DataItem("WS_CEUSOFfered")%></td>
    > </tr>
    > <tr>
    > <td>
    > <asp:checkbox id="chkCEUs" runat="server" Text="CEU's
    > Offered">
    > </asp:checkbox></td>
    > </tr>
    > </table>
    > </ItemTemplate>
    > </asp:DataList>
    > </ItemTemplate>
    > </asp:datalist></TD>
    > </TR>
    > <TR>
    > <TD>
    > <asp:Button id="Button1" runat="server"
    > Text="Button"></asp:Button></TD>
    > </TR>
    > <TR>
    > <TD></TD>
    > </TR>
    > </TABLE>
    >
    >
    >
    >
    >
    Elton Wang, Dec 29, 2005
    #2
    1. Advertising

  3. Darrin

    Darrin Guest

    Thanks!!!

    "Elton Wang" wrote:

    > Hi Darrin,
    >
    >
    >
    > Following code shows how to loop thru to get
    >
    > checkbox in the inner datalist:
    >
    >
    >
    > Dim innerList As DataList
    > Dim ckBox As CheckBox
    > For Each item As DataListItem In dlSessionDatesTimes.Items
    >
    > innerList = CType(item.FindControl("dlSessions"), DataList)
    > For Each innerItem As DataListItem In innerList.Items
    > ckBox = CType(innerList.FindControl("chkCEUs"), CheckBox)
    > ' process
    >
    > Next
    > Next
    >
    >
    >
    > HTH
    >
    >
    >
    >
    >
    > "Darrin" <> wrote in message
    > news:...
    > > Greetings, I am trying to get the checkbox value from a nested datalist
    > > once
    > > I press a button on my form (not within any of the datalist grids). I am
    > > using asp.net 1.1/vb.net
    > >
    > > The project I am working on provides users to register for a specific
    > > event
    > > and also view all the sessions going on for that event. See example
    > > below.
    > >
    > >
    > > Event: Microsoft Office Training
    > > Location: My City
    > > Date: Dec 21st
    > >
    > > Available Sessions:
    > > Wednesday Dec 21st, 9:00AM
    > > *Word 101 (checkbox)
    > > *Excel 200 (checkbox)
    > > *Access (checkbox)
    > >
    > > Wednesday Dec 21st 2:00PM
    > > *Access 200 (checkbox)
    > > *Powerpoint (checkbox)
    > >
    > > The first datalist (dlSessionDatesTimes) I created goes out to my SQL
    > > table
    > > to group the sessions by date and time for the particular event. As the
    > > dlSessionDatesTimes datalist is generated, I go out to my SQL table and
    > > gather all the realted sessions for that particular event, date and time.
    > > These are displayed in the second datalist (dlSessions). Next to each
    > > session I have a check box so the user can go through and select the
    > > session
    > > they wish to sign up for.
    > >
    > > The question:
    > > After I click the submit button on my form I want to caputure the values
    > > from the check box. How do I access the checkbox that is nested inside
    > > the
    > > other datalist (dlSessions)? Or is there another way?
    > >
    > > <asp:datalist id="dlSessionDatesTimes" runat="server"
    > > CellSpacing="15" CellPadding="5" Width="100%"
    > > RepeatColumns="1">
    > > <ItemTemplate>
    > > <TABLE class="Content" id="Table3" cellSpacing="1"
    > > cellPadding="5" width="100%" border="0">
    > > <TR>
    > > <TD
    > > class="Normal"><B><%#FormatDateTime(DataBinder.Eval(Container.DataItem,
    > > "WS_DATE"),1) & "-" & Format(DataBinder.Eval(Container.DataItem,
    > > "WS_StartTime"),"Short Time")%></B></TD>
    > > </TR>
    > > <TR>
    > > <TD></TD>
    > > </TR>
    > > <TR>
    > > <TD></TD>
    > > </TR>
    > > </TABLE>
    > > <asp:DataList id=dlSessions runat="server" CssClass="normal"
    > > DataSource='<%# ListSessions(DataBinder.Eval(Container.DataItem,
    > > "WS_DATE"),DataBinder.Eval(Container.DataItem, "WS_StartTime")) %>'
    > > RepeatLayout="Flow">
    > > <ItemTemplate>
    > > <table class="Normal">
    > > <tr>
    > > <td>
    > > Description:</td>
    > > <td><%# Container.DataItem("WS_Description")%></td>
    > > </tr>
    > > <tr>
    > > <td>Presenter:</td>
    > > <td><%# Container.DataItem("WS_Presenter")%></td>
    > > </tr>
    > > <tr>
    > > <td>Target Audience:</td>
    > > <td><%# Container.DataItem("WS_TargetAudience")%></td>
    > > </tr>
    > > <tr>
    > > <td>Location Area:</td>
    > > <td><%# Container.DataItem("WS_LocationArea")%></td>
    > > </tr>
    > > <tr>
    > > <td>CEUS Offered:</td>
    > > <td><%# Container.DataItem("WS_CEUSOFfered")%></td>
    > > </tr>
    > > <tr>
    > > <td>
    > > <asp:checkbox id="chkCEUs" runat="server" Text="CEU's
    > > Offered">
    > > </asp:checkbox></td>
    > > </tr>
    > > </table>
    > > </ItemTemplate>
    > > </asp:DataList>
    > > </ItemTemplate>
    > > </asp:datalist></TD>
    > > </TR>
    > > <TR>
    > > <TD>
    > > <asp:Button id="Button1" runat="server"
    > > Text="Button"></asp:Button></TD>
    > > </TR>
    > > <TR>
    > > <TD></TD>
    > > </TR>
    > > </TABLE>
    > >
    > >
    > >
    > >
    > >

    >
    >
    >
    Darrin, Dec 29, 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. V. Jenks

    server controls nested in DataList

    V. Jenks, Apr 21, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    528
    Martin Dechev
    Apr 22, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,844
  3. schapopa
    Replies:
    1
    Views:
    564
    schapopa
    Jan 12, 2006
  4. H5N1
    Replies:
    0
    Views:
    2,698
  5. Les Caudle
    Replies:
    0
    Views:
    1,968
    Les Caudle
    May 2, 2006
Loading...

Share This Page