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.
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.