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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DataList/FormView won't populate DropdownList

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
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>

View Complete Post

More Related Resource Links

DropDownList within FormView Error

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

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.


How to use parameter from Dropdownlist to populate Rep. Table

I successfully have populated a dropdownlist from a database. Now I need to create a sort of a Master/Detail situation - based on the selection in the DropDownlist, I need to populate a Repeating table. I just can't find any examples or tutorials on how to do this. I've tried stuff till my fingers were bleeding. Can someone help me figure this scenario out, please?

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

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

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.

DropdownList Selection to Populate TextBox

I have a dynamically generated dropdownlist, that lists e.g. Company Names. I want to be able to select a particular Company and display associated information e.g. Name, Address, City, State... etc. in text boxes adjacent to the list. I am trying to fire the following code from the dropdownlist "OnSelectedIndexChanged" property, but cannot 1) get the code to fire upon selection, and 2) populate the text boxes... any suggestions are appreciated!! Thanks CODE:     Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Facility.SelectedIndexChanged Dim FacilityAddressDetail As String  Dim FacilityAddress2 As String  Dim FacilityCity As String  Dim FacilityState As String  Dim FacilityZip As String Dim   FacilityAddressDetail = FacilityAddress2 = FacilityCity = FacilityState = FacilityZip =       mySettingsSIC = AppSettings   dgiSelectedIndexChange As DataGridItemFor Each dgiSelectedIndexChange In myDataGrid.ItemsCType(dgiSelectedIndexChange.FindControl("FacilityAddressDetail"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityAddress2"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityCity"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityState"), TextBox).TextCType(dgiSelec

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

Populate DropDownList in InsertItemTemplate after insert

I thought this one would be easy, but no go. What I am trying to do is the following: I have two DropDownLists in my InsertItemTemplate, each bound to its own datasource. After the fields in this form have been filled out and the ItemInserting event fires, I rebind the ListView to its datasource, but the DropDownLists turn out empty. I tried to bind them in the ItemInserting event and it seems they get filled, but nothing shows up in them when the page loads. I also tried to fill them in the ItemDataBound event, but the e.Item.ItemType == InsertItem doesn't do it. What is the solution?

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#?

Populate dropdownlist in Edit mode programatically


I'm trying to programatically populate some dropdownlists inside a formview in EDIT mode, like this below.

 Dim FVM As String = FormViewMemberProfile.CurrentMode.ToString

        If FVM = "Edit" Then

            Dim ddlDays As DropDownList = CType(FormViewMemberProfile.FindControl("ddlDays"), DropDownList)
            Dim ddlYears As DropDownList = CType(FormViewMemberProfile.FindControl("ddlYears"), DropDownList)

            Dim i As Integer = 1

            For i = 1 To 31

            Dim k As Integer

            For k = 1930 To 2008

        End If

I orginally had this running as part of the pagelaod event, but I'm thinking that b/c the page loads first, it doesn't populate the fields in EDIT mode until after the data is saved, and then page is reloaded. Now it knows it's in "Edit" mode. Am I thinking clearly here? Not sure if this is the order of things... Anyhow...

So I thought I should just use a formview_modechanged (or similar event) so when the user switches modes, it populates the fields - but I'm not sure which event I should use. I've tried "Modechanging", "modechanged", "prer

AJAX DropDownList won't populate.. error500.. code is working though.


Here's what I have.  I was able to debug and traverse through the webservice and return teh array back into the first call method of: return new CarsService()..  But back in the page_load method, I can't get it to update and show up in the page.  what am I doing wrong?!?!


<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                    <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
                     Category="Make" PromptText="Please select a make" LoadingText="[Loading makes...]"  

Need help to populate dropdownlist using Javascript


Hi, I'm doing a simple HTML form, that requires two dropdownlist - one that populates the month, and the other to populate the dates based on the month. For example, in January, there are 31 days. So the "date" dropdownlist will populate 1-31 in the "month" dropdownlist. The "date" dropdownlist will change to 1-28 for February when selected and so on...  Can someone please help me with the javascript section? I'm coding using javascript.

Many Thanks!


<title>Test Form</title>
<script language="JavaScript">
function testDate(){

var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var count = 0;
 if(location.href = document.form1.month.options[document.form1.month.selectedIndex].value) {
  for(var i=1; i<=(MonthDays[count]); i++) {
   document.writeln('<option value="'+i+'">' + i + '</option>');



<form id="form1" name="form1" method="GET">
  <label>Post Reminder:<br />
  <input type="text" width

jQuery - DropDownList and Textbox in DataList



I am using Dropdown Lists with Textbox in DataList Control.

I want to Enable disable Textbox depending on the Value selected in the Dropdownlist using jQuery.

Thanks for the Help.



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

Cannot populate the textbox with selection from dropdownlist. Thanks

I am not able to get the selection from dropdown into the detailsview template field during update. 

 <asp:TemplateField HeaderText="SupplierName" SortExpression="SupplierName">
                  <asp:TextBox ID="TextBox1Sup" runat="server"  Text='<%# Bind("SupplierName") %>'  Visible="True"></asp:TextBox>
                  <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" 
                  DataSourceID="AccessDataSource" DataTextField="CompanyName" 
                     DataValueField="CompanyName" AutoPostBack="True"  
                        > </asp:DropDownList>                    
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SupplierName") %>'></asp:TextBox>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("SupplierName") %>'>&
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