forsters
asked on
Keyword not supported: 'sqldatasource'.
Hi Folks,
Been learning my way round Visual Studio 2010, asp.net 4.0 & C# and am stuck on something silly.
I'm trying to add a drop-down list which is databound to a table in my sql database - as far as I can tell from my book etc I've done things right but as soon as I reference my DataSourceID in the dropdownlist I get an error:
Keyword not supported: 'sqldatasource'.
Not sure what I'm missing?
Been learning my way round Visual Studio 2010, asp.net 4.0 & C# and am stuck on something silly.
I'm trying to add a drop-down list which is databound to a table in my sql database - as far as I can tell from my book etc I've done things right but as soon as I reference my DataSourceID in the dropdownlist I get an error:
Keyword not supported: 'sqldatasource'.
Not sure what I'm missing?
BELOW: THE CODE IN MY PAGE
<asp:DropDownList
ID="DropDownList1"
DataSourceID="MyDataSource"
AppendDataBoundItems="true"
DataTextField="Description"
DataValueField="OptionID"
runat="server">
</asp:DropDownList>
<asp:SqlDataSource ID="MyDataSource"
ConnectionString="<%$ connectionStrings:Scanning %>"
SelectCommand="Select * From [JobType]"
runat="server">
</asp:SqlDataSource>
PAGE BEHIND CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class JobRequest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
WEB CONFIG CONNECTIONSTRINGS:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="Scanning" connectionString="SqlDataSource=servername; Initial Catalogue=Repro Tasklist;User ID=IntranetAdmin; Password=censored" providerName="System.Data.SqlClient"/>
<add name="Intranet" connectionString="SqlDataSource=servername; Initial Catalogue=IntranetDB;User ID=IntranetAdmin; Password=censored" providerName="System.Data.SqlClient"/>
</connectionStrings>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ahhh thanks Den HBR you're right it was my connection string format that was causing the problem, I have now changed it to:
<add name="Intranet"
providerName="System.Data. SqlClient"
connectionString= "server=OUR SERVER;database=OUR DATABASE;uid=USERNAME;pwd= PASSWORD"/ >
Brilliant thanks for pointing me in the right direction.
<add name="Intranet"
providerName="System.Data.
connectionString= "server=OUR SERVER;database=OUR DATABASE;uid=USERNAME;pwd=
Brilliant thanks for pointing me in the right direction.
you have to define provider in your sqldatasource queries, select, update, delete etc
providerName="System.Data.
Cheers