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

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

Help with displaying formview based on dropdownlist

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net

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?



View Complete Post

More Related Resource Links

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

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

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.


ListItem Dynamic DropDownList based on custom list entries.

I utilized the following solution to get the drop down list on the page and populate it dynamically, but it doesn't save the selected value back to the SPListItem object. Does anyone have a better solution possibly for this? http://geekswithblogs.net/SoYouKnow/archive/2010/01/21/sharepoint-populating-drop-down-list-field-with-data-from-different.aspx

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.

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

Filter dropdownlist based on previous selection



In my newform.aspx page in Helpdesk template (when I create a new service request), I have added a dropdownlist (lookup type) that list series of issues that user can select.

I would like to add another dropdownlist that further give more options based on the selection made on the first dropdownlist.

How can I drive this second list from the first one? Thanks.


DropdownList not displaying spaces in column



I have a dropdownlist which is bound to a SQL Server 2008 Table.

My issue is i am having some spaces in one of the columns.

But while binding the datasource to this table the column spaces are truncated .

This is illustrated below

The table name is DataTable

DataValue is the column which I needs to get displayed in the dropdownlist

ID                                                                   DataValue

1                                                                    P2P 1111111111111111                             &nb

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

Populate a dataGridview based on select an item in dropdownlist!


Hello all!

In window form,  there are two comboBoxs named cbo1, cbo2 with populate the same items in the dropdownlist as following: For examples,

Class A

Class B

Class C

I like to populate the data into two dataGridViews named dgv1, dgv2 based on selecting an item in two dropdownlists. The rules is if I select an item in the cbo1 to populate data in dgv1, and cbo2 with hide (remove) an selected item from cbo2 to avoid that the user selects the same item for populate the same data in the dgv2. In a brief, the displayed data in two dgv1, dgv2 are different. Any helps in C# code, I really appreciate it. Thanks in advance.

Displaying SharePoint lists in Web Parts

When you create a built-in or custom list in Microsoft Windows SharePoint Services, Windows SharePoint Services creates a Web Part, a basic building block of a SharePoint site, to display that list. These Web Parts are called List View Web Parts. Windows SharePoint Services stores List View Web Parts in the site collection Web Part gallery. (The site collection Web Part gallery is the most central gallery of Web Parts for a work group. By default, the gallery name is the name of the site, such as "Our Team Site Web Part Gallery." )

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

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