DropDownList in a Repeater

Discussion in 'ASP .Net' started by Guest, Dec 8, 2003.

  1. Guest

    Guest Guest

    Hi

    Can this be done?

    I can display this on the web page (so presumably some/all
    of the HTML is fine) but what I cannot do is get the data
    from the database to bind itself to the list. I've tried a
    few code variations but my latest is:

    OleDbConnection conn = null;
    OleDbDataReader reader = null;
    OleDbDataAdapter myadapter;

    string connectionString=ConfigurationSettings.AppSettings
    ["ConnectionString"];

    conn = new OleDbConnection(connectionString);
    OleDbCommand cmd=new OleDbCommand();
    cmd.CommandType=CommandType.StoredProcedure;
    cmd.Connection=conn;
    cmd.CommandText="[TASKDETAILS]";

    myadapter=new OleDbDataAdapter(cmd);

    try
    {
    conn.Open();
    reader=cmd.ExecuteReader(CommandBehavior.CloseConnection);
    }
    catch (Exception e)
    {
    Response.Write(e.Message);
    Response.End();
    }

    TaskRepeater.DataSource=reader;
    TaskRepeater.DataBind();

    and in the HTML it's:
    <asp:Repeater id="TaskRepeater" runat="server">
    <HeaderTemplate>
    <table border="0" width="594">
    <tr>
    <td align="left">Task</td>
    <td align="left">Project</td>
    <td align="left">Language</td>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td width="150">
    <%# DataBinder.Eval(Container.DataItem,"TASK_NAME") %>
    </td>
    <td width="150">
    <%# DataBinder.Eval(Container.DataItem,"LANG_NAME") %>
    </td>
    <td width="150">
    <asp:dropdownlist Width="88px" ID="LanguageDropDownList"
    CssClass="Standard-text" DataSource='<%# DataBinder.Eval
    (Container.DataItem,"LANG_NAME") %>'
    DataTextField="LANG_NAME" DataValueField="LANG_NAME"
    Runat="server"/>
    </asp:dropdownlist>
    </td>

    Unfortunately, this gives me the error message:
    DataBinder.Eval: 'System.Char' does not contain a property
    with the name LANG_NAME.
    I know that my SQL is correct since I've double checked
    that LANG_NAME comes through elsewhere.

    Can anyone help me out?
    Thanks in advance.
    Guest, Dec 8, 2003
    #1
    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. Replies:
    0
    Views:
    840
  2. Replies:
    0
    Views:
    2,862
  3. Replies:
    1
    Views:
    7,007
    Karl Seguin
    Aug 10, 2005
  4. uncensored
    Replies:
    0
    Views:
    791
    uncensored
    Oct 25, 2006
  5. Microsoft

    Repeater inside a Repeater

    Microsoft, Aug 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    190
    Microsoft
    Aug 21, 2006
Loading...

Share This Page