Newbie Alert: Please help with repeater control and list box

Discussion in 'ASP .Net' started by John sorCrer, Mar 2, 2004.

  1. John sorCrer

    John sorCrer Guest

    Hi Guru's,

    I am new to asp.net!

    I can create a repeater control but would like to add a select list to
    it as follows:

    <%@ Page Language="vb" debug=true %>
    <%@ import Namespace="System.Data" %>
    <%@ import Namespace="System.Data.SqlClient" %>
    <script runat="server">

    Sub Page_Load(sender As Object, e As EventArgs)
    Dim myConnection As SqlConnection
    Dim myCommand As SqlDataAdapter
    myConnection = New SqlConnection("server=local;user
    id=whocares;database=dbSeekersClientApp;Trusted_Connection=false")
    myCommand = New SqlDataAdapter("SELECT ID, username, password,
    firstname, surname, account_live FROM t_managers", myConnection)
    Dim ds As Dataset = new DataSet()
    myCommand.Fill(ds)

    MyRepeater.DataSource = ds
    MyRepeater.DataBind()

    End SUb

    </script>
    <html>
    <head>
    </head>
    <body>

    <form action="intro1.aspx" method="post" runat="server">

    <ASP:Repeater id="MyRepeater" runat="server">
    <HeaderTemplate>
    <table width="100%" style="font: 8pt verdana">
    <tr style="background-color:DFA894">
    <th>
    User ID
    </th>
    <th>
    Surname
    </th>
    <th>
    Firstname
    </th>
    <th>
    Username
    </th>
    <th>
    Password
    </th>
    <th>
    Access
    </th>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr style="background-color:FFECD8">
    <td>
    <%# DataBinder.Eval(Container.DataItem, "ID") %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem, "surname")
    %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem,
    "firstname") %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem,
    "username") %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem,
    "password") %>
    </td>
    <td>
    >>>>> Problem code


    <asp:DropDownList id="dList1" width=100 runat="server">
    <option
    value=<%#DataBinder.Eval(Container.DataItem, "account_live")%>>
    <%# DataBinder.Eval(Container.DataItem, "account_live") %>
    </option>
    >>>> Problem code ends


    </asp:DropDownList>
    </td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </ASP:Repeater>
    </form>
    </body>
    </html>


    Any pointers?
    John sorCrer, Mar 2, 2004
    #1
    1. Advertising

  2. Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "John sorCrer" <> wrote in message
    news:...
    > Hi Guru's,
    >
    > I am new to asp.net!
    >
    > I can create a repeater control but would like to add a select list to
    > it as follows:
    >
    > <%@ Page Language="vb" debug=true %>
    > <%@ import Namespace="System.Data" %>
    > <%@ import Namespace="System.Data.SqlClient" %>
    > <script runat="server">
    >
    > Sub Page_Load(sender As Object, e As EventArgs)
    > Dim myConnection As SqlConnection
    > Dim myCommand As SqlDataAdapter
    > myConnection = New SqlConnection("server=local;user
    > id=whocares;database=dbSeekersClientApp;Trusted_Connection=false")
    > myCommand = New SqlDataAdapter("SELECT ID, username, password,
    > firstname, surname, account_live FROM t_managers", myConnection)
    > Dim ds As Dataset = new DataSet()
    > myCommand.Fill(ds)
    >
    > MyRepeater.DataSource = ds
    > MyRepeater.DataBind()
    >
    > End SUb
    >
    > </script>
    > <html>
    > <head>
    > </head>
    > <body>
    >
    > <form action="intro1.aspx" method="post" runat="server">
    >
    > <ASP:Repeater id="MyRepeater" runat="server">
    > <HeaderTemplate>
    > <table width="100%" style="font: 8pt verdana">
    > <tr style="background-color:DFA894">
    > <th>
    > User ID
    > </th>
    > <th>
    > Surname
    > </th>
    > <th>
    > Firstname
    > </th>
    > <th>
    > Username
    > </th>
    > <th>
    > Password
    > </th>
    > <th>
    > Access
    > </th>
    > </tr>
    > </HeaderTemplate>
    > <ItemTemplate>
    > <tr style="background-color:FFECD8">
    > <td>
    > <%# DataBinder.Eval(Container.DataItem, "ID") %>
    > </td>
    > <td>
    > <%# DataBinder.Eval(Container.DataItem, "surname")
    > %>
    > </td>
    > <td>
    > <%# DataBinder.Eval(Container.DataItem,
    > "firstname") %>
    > </td>
    > <td>
    > <%# DataBinder.Eval(Container.DataItem,
    > "username") %>
    > </td>
    > <td>
    > <%# DataBinder.Eval(Container.DataItem,
    > "password") %>
    > </td>
    > <td>
    > >>>>> Problem code

    >
    > <asp:DropDownList id="dList1" width=100 runat="server">
    > <option
    > value=<%#DataBinder.Eval(Container.DataItem, "account_live")%>>
    > <%# DataBinder.Eval(Container.DataItem, "account_live") %>
    > </option>
    > >>>> Problem code ends

    >
    > </asp:DropDownList>
    > </td>
    > </tr>
    > </ItemTemplate>
    > <FooterTemplate>
    > </table>
    > </FooterTemplate>
    > </ASP:Repeater>
    > </form>
    > </body>
    > </html>
    >
    >
    > Any pointers?
    Alvin Bruney [MVP], Mar 4, 2004
    #2
    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. Darren Smith
    Replies:
    5
    Views:
    5,498
    dsmith
    May 10, 2004
  2. iamaran
    Replies:
    1
    Views:
    407
    iamaran
    Dec 23, 2005
  3. KK
    Replies:
    2
    Views:
    498
    Big Brian
    Oct 14, 2003
  4. Mersh
    Replies:
    0
    Views:
    473
    Mersh
    Mar 13, 2007
  5. Ganesh
    Replies:
    0
    Views:
    533
    Ganesh
    Jun 29, 2007
Loading...

Share This Page