.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

DropDownList within FormView Error

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net
I have a FormView which works find and I have added a new DropDownList within the form which references another table to which I need to select a value,
I have added the dropdownlist2 and setup a new connection string to this, when I run the page I get this error:

Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.
any help would be greatly

View Complete Post

More Related Resource Links

Help with displaying formview based on dropdownlist


I have a formview1 with a dropdownlist1 in the insert template. Based on the value of that dropdownlist I would like to display a second formview on the same page in insert mode so that I can write data to two different tables.

How can I accomplish this?

Is this the best way to do it?



Formview PagerTemplate DropDownList Navigation


Does anyone know if its possible to use a DropDownList within the PagerTemplate to navigate to a specific record?  I have been able to place the DropDownList outside of the FormView and PagerTemplate and make it work, however, I can't get it to work inside the PagerTemplate.


FormView EditItemTemplate DropDownList loaded from codebehind via stored procedure

I'm attempting to load DropDownLists from the C# codebehind as the FormView switches modes to Edit and displays the EditItemTemplate.  I present the data in a FormView ItemTemplate using text boxes.  When the user selects Edit, I have been attempting to load the EditItemTemplate dropdownlists by creating a dataset and binding it to the control, without success.  I've successfully loaded them in previous projects from within the .aspx code using <asp:ListItem> and within the C# code behind using Control.Items.Add(new ListItem), which are essentially the same thing of course .  This project is different in that I want to get the data from a stored procedure on a MSSQL server. In my latest attempt, I can see the data in the datasets.  I'm getting "Error connecting to database.'eitRace' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value" I include the code below.  If someone could point me to an example I would be greatful.  There has to be an elegant way of accomplishing this. Thank You, rlbaum *************************************************** <EditItemTemplate> <asp:Button ID="updatebutton" runat="server" CausesValidation="false" Text="Update&quo

DropDownList inside FormView Insert Template

Hi, I am trying to change the textboxes in the FormView insert template to dropdownlists but they keep setting the parameters to null.   Here's what I have:  <asp:DropDownList ID="ddlYearOfQualification" SelectedValue='<%# Bind("YearOfQualification") %>' runat="server"> </asp:DropDownList> In Page_Load CType(frmSurvey.FindControl("ddlYearOfQualification"), DropDownList).Items.Add(New ListItem("2010", "2010"))CType(frmSurvey.FindControl("ddlYearOfQualification"), DropDownList).Items.Add(New ListItem("2009", "2009"))   and in the SqlDataSource InsertCommand="INSERT INTO [tblSurvey] (... [YearOfQualification] ...) VALUES ( ... @YearOfQualification ... ) And in insert parameters: <asp:Parameter Name="YearOfQualification" Type="Int16" /> And the insert fails with YearOfQualification as null. If I sue the standard textbox: <asp:TextBox ID="YearOfQualificationTextBox" runat="server"                 Text='<%# Bind("YearOfQualification") %>' /> It works.   Any ideas? Many thanks in advance.

Update in formview doesn't work, but I don't get an error message?

I have a datasource:<asp:SqlDataSource ID="MySQLProfielDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:WAPMySQLConnStr %>" InsertCommand="INSERT INTO usergegevens(UserId, Geslacht, Voornaam, Tussenvoegsel, Achternaam, Adres, Huisnummer_toev, Postcode, Woonplaats, TelnrV, TelnrM, Geboortedatum) VALUES (@Param1, @Param2, @Param3, @Param4, @Param5, @Param6, @Param7, @Param8, @Param9, @Param10, @Param11, @Param12)" ProviderName="<%$ ConnectionStrings:WAPMySQLConnStr.ProviderName %>" SelectCommand="SELECT UserId, Geslacht, Voornaam, Tussenvoegsel, Achternaam, Adres, Huisnummer_toev, Postcode, Woonplaats, TelnrV, TelnrM, Geboortedatum FROM usergegevens WHERE (UserId = @Param1)" UpdateCommand="UPDATE usergegevens SET Geslacht = @Param1, Voornaam = @Param2, Tussenvoegsel = @Param3, Achternaam = @Param4, Adres = @Param5, Huisnummer_toev = @Param6, Postcode = @Param7, Woonplaats = @Param8, TelnrV = @Param9, TelnrM = @Param10, Geboortedatum = @Param11 WHERE (UserId = @Param12)" onselecting="MySQLProfielDataSource_Selecting" onupdating="MySQLProfielDataSource_Updating" onselected="MySQLProfielDataSource

DropDownList in Formview has events masked

Hello all, I'm new to ASP.Net (using 2010 pro version) and I have a problem with ASP.NETthat is giving me fits trying to solve it. I am trying to catch the SelectedIndexChanged event on the ddlParent DropDownList and use it's SelectedValue in code behind to repopulate the ddlChild DropDownList.  I've distilled it down to some very simple test code and I'd appreciate some understanding of why this is not working as expected and what I should do to make it work (In VB please). I get the following compiler error: Compiler Error Message: BC30456: 'ddlParent_SelectedIndexChanged' is not a member of 'ASP.test_aspx'. Test Case code follows: <%@ Page Language="vb" AutoEventWireup="True" CodeBehind="Test.aspx.vb" Inherits="WebApplication2.Test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server">    <title></title></head><body>    <form id="form1" runat="server">           <asp:DropDownList ID="ddlParent" runat="server"   &nbs

DataList/FormView won't populate DropdownList

I have a ddl inside the formview that I can't figure out how to wire up properly. The formview contains detail info, but the ddl needs to list the entire set to items. Then I want the ddl's selected value be set from the recordset intended  for the formview. I think it's just a timeing issue s I would like your help. Thanks, - EJM. Here my code somewhat reduced to save space...<asp:DataList Width="700" ID="DlMembers" runat="server" DataKeyField="Ident" OnItemCommand="DlMembers_ItemCommand" OnDeleteCommand="DlMembers_DeleteCommand" > <HeaderTemplate> <table border="1" cellpadding="2" cellspacing="0"> <tr align="left" valign="top"> <th nowrap>First Name</th><th nowrap>Last Name</th><th nowrap>Address</th><th nowrap>Email</th><th nowrap>Home Phone</th><th nowrap>Work Phone</th><th nowrap>Cell Phone</th><th nowrap>Position</th><th nowrap>Admin</th><th nowrap>Comments</th><th> </th><th> </th></tr></HeaderTemplate><ItemTemplate>

formview + dropdownlist



I have a table which has several categories like animals, birds etc.

When I select animals in dropdown I should get all the details of all animals which i have in database should display in formview. How can i do tht using C#?

FormView Disappears or gives a SQL Conversion Error


I am using a gridview for control parameters for a formview on the same page.

I keep getting the SQL Error below.  I have painfully looked through the code to see what the deal is and I have a feeling it has to do with the control parameter. When I test the query in the wizard it gives me back what I should get back.

When I run the page and code I get the error below. This value is the CorpID and it is a varchar. So I am thinking the way the parameters are configured is not correct.

I have no issues with the Insert Template, just the edit template. So it eithers gives me the SQL error or the Formview does not appear.

Any guidance on how to map the parameters from a GrdiView would be aprreciated.

SQL Error:Conversion failed when converting the varchar value 'X123456' to data type int.

SQL for Form View

select userid, FirstName , LastName ,PermissionLevelDesc, a.Permissionlevelid as permissionlevelid,
case active_flg when 1 then 'Active'
else 'Inactive' end as Active_Status,active_flg,CorpID
from dbo.NPE_APP_Users a inner join dbo.NPE_APP_SEC_PROFILE b
on a.PermissionLevelID = b.PermissionLevelID
where userid = @userid and corpid=@corpid and a.permissionlevelid=@permissionlevel

DropDownList error message: "value not found in the list"


Inside a FormView control, I have a DropDownList that populates a SQL column with city names. The SQL column type is nchar(50) -- I set it for 50, since the city names can be short or very long. The DropDownList contains all the city names. When a new record is created in SQL via this FormView control, the DropDownList successfully populates the column cell.

However, when I try to edit that record (using the edit template in FormView), I get the above error message...I believe the retrieved entry is not matching the entry in the list, because SQL isn't just storing the number of characters that a given city has (say "6" for Boston), it is storing/retrieving 50 characters (6 + 44 null spaces = 50 characters)--and thus DropDownList doesn't recognize that the entry is just "Boston"...How can I resolve? How can I ensure that there are no extra spaces recorded in a SQL cell beyond what is needed to accomodate the name of any given city?  Is this a SQL task or can it be resolved in ASP.NET?  Thank you. 

DropDownList - Selected Value not in List Error.


If you use a dropdownlist and the selected value for the ddl is not in the datasource.  This can happen in an existing record if the user changes the datasource, e.g. deletes a row.  ASP.net throws an exception.

To get around this problem, you can not bind the SelectedValue in the aspx page and use code like the following in the FormView_DataBound Event. 

'-- Set DropDownList - Selected Value
      If Me.FormView1.CurrentMode = FormViewMode.Edit Then
         Dim ddl1 As DropDownList = Me.FormView1.FindControl("ddlTest")
         If Not IsDBNull(ddlTest) Then
            Dim strValue As String = (DataBinder.Eval(FormView1.DataItem, "DataFIeldName").ToString())
            If ddl1.Items.IndexOf(ddl1.Items.FindByValue(strValue)) >= 0 Then
               ddl1.SelectedValue = DataBinder.Eval(FormView1.DataItem, "DataFieldName")

Dropdownlist error: SelectedValue which is invalid because it does not exist in the list of items.


I have a dropdownlist in a detailsview edit Item template. Also I have two tables - Employee and Main. In the Employee table I have column EmpId and AssignedTo. In the main table I have EmpId which is connected to the Employee table. 

The detailsView has a label which shows the AssignedTo name for a particular record and it works fine. But if I click the edit button to shwo the dropdownlist in the editItemTemplate it is givig me the above error.

The code is:

<asp:DetailsView ID="dtvAssign" runat="server" AutoGenerateRows

FormView Error when inserting


When doing an insert using a FormView i get the following error.

"Could not find a property named 'Project.IID' on the type specified by the DataObjectTypeName property in ObjectDataSource 'UserStoryDataSource' "

Other posts have suggested removing the value from the DataObjectTypeName. Which I have done but that just results in the error "ObjectDataSource 'UserStoryDataSource' could not find a non-generic method 'Save' that has parameters: ListItemID, UserStoryID, Name, Project.IID, AsUser, Action, Reason, Priority, Complexity, Story."

I think the error has something to do with the binding the Selected Value of the Project drop down list to the Project.IID property of the UserStoryDTO class.

What is the cause of this error and how can i fix it?

The insert Item template and datasource code is below.

                <asp:Label runat="server" AssociatedControlID="ListItemIDTextBox">ListItemID</asp:Label>
                <asp:TextBox ID="ListItemIDTextBox" runat="server"  Text='<%# Bind("ListItemID") %>' />
                <br />
                <asp:Label ID="Label1" runat="server" AssociatedControlID="Lis

Populating DropDownList in FormView from Code Behind


On my formview I have a drop down list that is populated with the names of the files in a certain directory. This works fine, but when the drop down list selected value is bound to the database field I get the following error :

'ImageFileDropDownList' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

I have setup other drop down lists in the same formview populated from SqlDataSources and these all work fine. I can see perhaps why this is an issue because I have not specified a DataValueField or a DataTextField for this drop down that is populated in code (whereas I can for the SQL bound ones) because I'm not sure what these settings would be.

I need to have a "blank" option as well so that the field does not default to the first value in the list.

My code (I have stripped out some meaningless controls) :

<asp:FormView ID="FormView1" runat="server" DataKeyNames="BannerID" DataSourceID="SqlDataSource2" OnItemDeleted="FormView1_ItemDeleted">
    <table width="100%" cellspacing="0" cellpadding="4">                          

Interesting javascript error with formview


hii.. I have a formview which implements the edit, delete and new operations on database. The form is working absolutely fine. But now i had inserted the code of the formview into a modalbox created through javascript.

The form now displaying the data perfectly. But, when i click on any buttons to do any operation.. it is throwing an exception at the following line..


and the exception throwed is

Microsoft JScript runtime error: Object expected

Can some one tell me what is the problem..

I want to post to server from the modalbox form. Please explain if we can directly post back to server from modalbox or not ?

jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend