The DataSourceID of 'ddlDevice' must be the ID of a control of type IDataSource. 'dsMain' is not an IDataSource.

I seem to be having trouble binding the objects in my page to the
datasource. The subject line contains the error message that I keep
receiving.  I am trying to bind a dropdownlist with my
datasource.  I noticed that if I click on the droplist, go to the
properties window and try to select a datasource; nothing is listed.



0
jarnold646
8/30/2005 6:55:02 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

7 Replies
1204 Views

Similar Articles

[PageSpeed] 25
Get it on Google Play
Get it on Apple App Store

Post the code for filling dsMain

NC...
0
NC01
8/30/2005 7:40:21 PM

How did you setup the datasrouce?

I think you didnt use the wizard to connect into database. You will not see any datasrouce in the properties window till u use the wizard to (server explorer) create the database connection and dataadapter + dataset

regards
HTH


ASP.NET Hosting (HostingFest)
0
smiling4ever
8/30/2005 8:52:05 PM
What kind of datasource are you using, and have you established a connection to it yet? Do you have a dataadapter object?

smtraber
Victory is mine!!
0
smtraber
8/31/2005 8:21:04 AM
Here is the code, I am trying to use "SqlDatasourceControl-dsMain." Thank you for your response.

<%@ Page Language="vb" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    Function GetDevice() As System.Data.DataSet
            Dim connectionString As String = "server='(local)'; trusted_connection=true; database='master'"
            Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
   
            Dim queryString As String = "SELECT [main].[id], [main].[device] FROM [main]"
            Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
            dbCommand.CommandText = queryString
            dbCommand.Connection = dbConnection
   
            Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
            dataAdapter.SelectCommand = dbCommand
            Dim dataSet As System.Data.DataSet = New System.Data.DataSet
            dataAdapter.Fill(dataSet)
   
            Return dataSet
        End Function
   
        Sub Page_Load(Sender As Object, E As EventArgs)
   
        GetDevice()
   
   
        If Not Page.IsPostBack Then
           ddlDevice.DataTextField = "device"
            ddlDevice.DataSource = dsMain
            ddlDevice.DataBind()
        End If
   
    End Sub
   
    Sub ddlDevice_SelectedIndexChanged(sender As Object, e As EventArgs)
   
    dim myDs as new system.data.dataset
   
     'myDs = GetDevice(ddlDevice.SelectedIndex)
     DataList1.DataBind()
    End Sub
   
    Sub DataList1_SelectedIndexChanged(sender As Object, e As EventArgs)
   
    End Sub

</script>
<html>
<head>
</head>
<body>
    <asp:DropDownList id="ddlDevice" AutoPostBack="True" OnSelectedIndexChanged="ddlDevice_SelectedIndexChanged" DataSourceID="dsMain" Width="241px" runat="server"></asp:DropDownList>
    <wmx:SqlDataSourceControl id="dsMain" runat="server" DeleteCommand="" UpdateCommand="" SelectCommand="SELECT * FROM [main]" ConnectionString="server='(local)'; trusted_connection=true; database='master'"></wmx:SqlDataSourceControl>
    <asp:DataList id="DataList1" OnSelectedIndexChanged="DataList1_SelectedIndexChanged" runat="server" BorderStyle="Solid" BackColor="#C0C0FF" BorderColor="Black">
        <HeaderTemplate>
            <p>
                Device ID:<asp:Label id="lblDevice" runat="server"></asp:Label>&nbsp;
            </p>
            <p>
                Username:<asp:Label id="lblUser" runat="server" text="Label"></asp:Label>
            </p>
            <p>
                Password:<asp:Label id="lblPass" runat="server" text="Label"></asp:Label>
            </p>
            <p>
                URL:<asp:Label id="lblURL" runat="server" text="Label"></asp:Label>
            </p>
        </HeaderTemplate>
    </asp:DataList>
</body>
</html>


0
jarnold646
8/31/2005 1:22:25 PM
I know that in Visual Studio .net you can open the solution explorer,
select a connection and drag tables into the application or class
module.  However, I am trying to create these pages using ASP.net
Web Matrix.  Which seems to work differently. Thank you for your
response.
0
jarnold646
8/31/2005 1:32:03 PM
Add outside of any method:
   Dim dsMain As System.Data.DataSet = New System.Data.DataSet("dsMain")

and change your Page_Load event handler to:
        Sub Page_Load(Sender As Object, E As EventArgs)
   
        dsMain = GetDevice()

      ...

Now try it.

NC...
0
NC01
8/31/2005 2:06:13 PM
It works!  Thanks!  I figured that all the coding needed was in the function. Anyway, thanks again.
0
jarnold646
8/31/2005 2:40:02 PM
Reply:

Similar Artilces:

The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource. A control with ID 'AccessDataSource' could not be found.
what i'm missing that i get the error: The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource.  A control with ID 'AccessDataSource' could not be found.      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="NewsId"                  EmptyDataText="There are no data records to display.">          &nb...

The DataSourceID of 'gv2' must be the ID of a control of type IDataSource. A control with ID 'objDs1' could not be found.
i have a radiobutton list and gridview and a object data source at runtime i'm changing the object data source by clicking on the radiobutton list selected index changed and here is my source code....          <asp:RadioButtonList runat="server" ID="rblView" RepeatDirection="Horizontal" RepeatLayout="Flow" AutoPostBack="True" OnSelectedIndexChanged="rblView_SelectedIndexChanged">                &nb...

The DataSourceID of 'DetailsView1' must be the ID of a control of type IDataSource. A control with ID 'AccessDataSource1' could not be found.
 Anyone help with this? i have tried lots of ways to query this database and create the insert command, including making my own data sets and setting it up that way with my own custom SQL statement.....this did not work, so i though i would use VWD 2008's own tools to create the insert, i have been left with the following error: The DataSourceID of 'DetailsView1' must be the ID of a control of type IDataSource.  A control with ID 'AccessDataSource1' could not be found.   Everything looks ok to me. Code below:   <%@ Page Title="" Lan...

How do fix the error The DataSourceID of 'DataGrid1' must be the ID of a control of type IDataSource. A control with ID 'SqlMedTable' could not be found.
How do you fix the error: The DataSourceID of 'DataGrid1' must be the ID of a control of type IDataSource.  A control with ID 'SqlMedTable' could not be found.Here is the code.protected void Page_Load(object sender, EventArgs e) {if (!IsPostBack) {MedicalClassLibrary.Connection c = new MedicalClassLibrary.Connection(); c.GetMedicalTable();DataGrid1.AutoGenerateColumns = true; DataGrid1.DataSource = c.DS;InputDiv.Visible = false;Label1.Visible = false; txtRx.Focus(); } } Here is the class medhod:public void GetMedicalTable() {string medTable = "SELECT ...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

The DataSourceID of '' must be the ID of a control of type IDataSource
I have a grid view with dropdown list. I have to be able to edit it by clicking on ‘Edit’ link button. Dropdown at this point should be populated with data.1. I need to display one of the values of the dropdown in the grid (read only). This value is what is coming to populate entire row of the grid view. Even I do not have an error on initial load of grid view and while debugging I see a data coming to populate grid view row and a dropdown, the column is empty. How can I populate a value of the grid view column of the row as a selected field of the dropdown? 2. I am getting an error when l...

DataSourceID of 'controlname' must be the ID of a control of type IDataSource.
When I use the following code, I get this error:The DataSourceID of 'PSAnswersGridView' must be the ID of a control of type IDataSource.  A control with ID 'Key_Trait_Analysis_ObjectDataSource' could not be found.I am trying to define an objectdatasource in code-behind and bind it to a gridview:Partial Class Admin_StuffInherits System.Web.UI.PageProtected Key_Trait_Analysis_ObjectDataSource As ObjectDataSourceProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadIf Not Page.IsPostBack Then...  Key_Trait_Analysis_ObjectDataSource...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

System.Web.HttpException: Control 'ctl00_main_Wizard1' of type 'Wizard' must be placed inside a form tag with runat=server.
I can't figure out why it is saying that. . . the content window that it is in and the wizard itself both have runat="server" set in their tags 2 things to check..1. Do you have the main <form runat="server'></form> tags ( the wizard would be between these tags)2. look for typos - something mistyped will prevent .Net from seeing the form tagHope That HelpsAll that wander, are not lost...What were we talkin bout...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Control 'WzdResults_GridView2' of type 'GridView' must be placed
inside a form tag with runat=server. " That is the error message I get when I try to export my gridview data in excel. Ok, here are the requirements: I have wizard control which has 4 steps, each presenting data in gridview after running some queries on SQL server based on dates given by user. I get data in the gridview fine. Now, I want to generate a report, either using reportviewer or placing that data in excel spreadsheet. I tried with reportviewer. In windows form it works fine, but I could not get it running in web application. Below is the code for reportviwer: ReportViewer1.Pro...

Web resources about - The DataSourceID of 'ddlDevice' must be the ID of a control of type IDataSource. 'dsMain' is not an IDataSource. - asp.net.web-forms

Resources last updated: 2/3/2016 1:00:14 PM