DropDownList in a Repeater

G

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top