Results 1 to 1 of 1

Thread: Nested Dropdown list inside a datalist: Retrieve values ** Resolved **

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member MarkusJ_NZ's Avatar
    Join Date
    Jun 2001
    Posts
    375

    Thumbs up Nested Dropdown list inside a datalist: Retrieve values ** Resolved **

    Hi, I have a datalist that contains a textbox as well as a dropdown list.

    For each single row in the datalist the associated dropdown list can have at least one value

    Picture attached

    What I would like to be able to do is when a single update button is clicked the textbox value along with the associated dropdown value is printed for each row in the datalist.

    The number of rows in the datalist can vary. Here is my Datalist code

    VB Code:
    1. <asp:DataList id="DataList1" runat="server" DataKeyField="PersonID">
    2.                     <ItemTemplate>
    3.                         <asp:TextBox ID="txtName" Runat="server" Text='<%# Container.DataItem("Firstname") %>' Enabled="False">
    4.                         </asp:TextBox>
    5.                         </td>
    6.                         <td>
    7.                             <asp:DropDownList ID="dlNotChild" Runat="server" DataSource="<%# GetNotChild() %>" DataTextField="PersonName" DataValueField="PersonID">
    8.                             </asp:DropDownList>
    9.                                                     </td>
    10.                     </ItemTemplate>
    11.                 </asp:DataList>

    The main datalist is bound to a dataview as is the dropdown list (GetNotChild routine)

    Thanks for your time
    Regards
    MarkusJ

    ======================

    I have fixed it new code below

    VB Code:
    1. <asp:dataList id="DataList1" runat="server" DataKeyField="DeptID">
    2.                     <ItemTemplate>
    3.                         <asp:TextBox ID="txtName" Runat="server" Text='<%# Container.DataItem("DeptName") %>' Enabled="False">
    4.                         </asp:TextBox>
    5.                         </td>
    6.                         <td>
    7.                             <asp:dropDownList ID="dlNotChild" Runat="server" DataSource="<%# GetNotChild() %>" DataTextField="DeptName" DataValueField="DeptName" AutoPostBack="True" OnSelectedIndexChanged="bollo">
    8.                             </asp:dropDownList>
    9.                         </td>
    10.                     </ItemTemplate>
    11.                 </asp:dataList></P>

    And the main Bollo function is this...

    VB Code:
    1. Public Sub Bollo(ByVal sender As Object, ByVal e As System.EventArgs)
    2.         Response.Write(CType(sender, DropDownList).SelectedItem.Text)
    3.         Response.Write(DataList1.DataKeys(CType(sender, DropDownList).SelectedIndex))
    4.     End Sub
    Attached Images Attached Images  
    Last edited by MarkusJ_NZ; Nov 19th, 2003 at 10:26 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width