.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

Cascading DropDownLists in DetailsView

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
Hi guys,My first post ;]I am a beginner in asp.net and therefore, cause problems that for me seem unsolvable.I hope someone can help me resolve this. Thank you.Here is the case:I use Visual Studio 2008 ASP.NET 3.5I have a DetailsView control with several fields that is in insert mode. Three of them are the source of my problems and headaches.I have three DropDownLists in template fields.The first one is OK, bound to it's designated field in table1 in the database. The next two however have to change their bound tables according to the SelectedValue. So far, I've managed to get it working, BUT when I insert the data I've entered, these two DropDownLists are not entered into the database.DropDownList3 - the list that controls the other two DDLsDropDownList4 and DropDownList5 - the list that need to change their items accordinglyDropDownList3 has six different values, so I have 6 tables for each of the other two DDLs However I have only tried with one to see if it would work, that's why the Sub seems incomplete.Here is the relevant part of the code: <asp:TemplateField HeaderText="Category" SortExpression="category"> <EditItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("category") %>'></asp:T

View Complete Post

More Related Resource Links

DropDownLists inside Detailsview INSERT cant get to work.



I'm having a DetailsView which has two DropDownList's inside so I should be able to pick 2 values for the field from DDL instead of writing something for it. But I cant get it to Insert any new values to my Database...

Can anyone help me with this? I'm pasting my code and table details here below.

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
        CellPadding="4" DataKeyNames="SignUpKey" DataSourceID="LinqDataSource1"
        DefaultMode="Insert" ForeColor="#333333" GridLines="None" Height="50px"
        Width="125px" oniteminserted="DetailsView1_ItemInserted"
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

How do I implement a form of cascading dropdownlists and associated controls?


I've got 3 SqlDataSource controls, and 2 dropdownlists and 1 detailsview on a page.  The first SqlDataSource is associated with the first dropdownlist, and second SqlDataSource (which is filtered based upon the selection chosen in the first dropdownlist) is associated with the second dropdownlist and the third SqlDataSource (which is filtered both by the selection of the first dropdownlist and the second dropdownlist) is associated with the detailsview.   The idea is the user selects something in the first dropdownlist, and it is supposed to update what is returned by the second SqlDataSource control and second dropdownlist, and that in turn is supposed to change what is returned in the third SqlDataSource control and it's associated detailsview.  All of the dropdownlists have AutoPostback set to True.

But it's not working.  Why is that?

Master-Detail with the GridView, DetailsView and jQuery's ThickBox

One more article about grids from Matt Berseth. This time he shows how to create master-detail with the gridview, detailsview and jQuery's ThickBox. He writes:
So I thought I would check some of this out and along the way rebuild my Master-Detail with the GridView, DetailView and ModalPopup Controls and replace the ModalPopup with jQuery's ThickBox. I found it pretty interesting - read on to see how it went

Issue in Infopath 2007 browser form - cascading dropdown using owssvr.dll filter view


Referring the below link, I created a cascading dropdown. The parent dropdown has sharepoint list as datasource and the child dropdown has xml datasource that points to owssvr.dll filter view. The cascading drop down works fine in preview but throws error after publishing as admin approved form - "form cannot run the specified query" exception when trying to execute xml datasource i.e., when a value is selected in parent dropdown. The security is 'Full Trust". In the event viewer the error message states "401 unauthorised" for the user a/c. the xml data source is an approved udcx file and in central admin, have enabled cross domain for infopath service. I have tried different solution provided in tech forums but issue still exists. Not sure whether Im missing something. Can someone guide me in fixing this issue?

Link Reffered:



cascading functionality in infopath 2007


Hello ,

I have a few drop downs in my browser based infopath 2007 forms and they  have cascading functioanlity ie they get filtered data..for filtering i qam using a web service..now the issue is that say i have 4 drop downs and for getting the fourt drop down's value the web service takes as input the second and the third's drop down value..now what is happening is that if based on the second drop down value if there is no value returned for third drop down then i cannot get to fourt drop down's value whichi should as it has value irrespective of whether the third drop down has some value or not....this is only the issue when i access the form in browser ..when i access it through the client infopath then it's working good...but in browser form the event is not firing when i select the emty value in third drop down...

Can somebody please tell me what to do..


get edited value from detailsview


hi sir/madam,

im using asp.net 3.5 sp1 and tried to search the internet but could not find any answer, i have a problem with detailsview as below, when user click on btnEdit, it will call detailsview.changemode(edit) and then allow user to enter data into the textbox, after that user will click on btnsave and then to read the value from txtname and process the value. my question is how do i get the value from txtname? i dont want to use any datasource component and i have tried call the DetailsView1.FindControl("txtname") and it returned txtbox with empty text. hope your can give me some clue where did i missed out.

any helps will be appreciated, thanks.

      <asp:DetailsView ID="DetailsView1" runat="server"  Height="50px" Width="125px" >
<asp:TextBox ID="txtname" runat="server" Text='<%# Bind("name") %>'></asp:TextBox>
<asp:Button ID="btnEdit" runat="server" Text="

listview 3.5 bind dropdownlists edit item template VB.NET


I am trying to do this with many issues of data binding doubling the amount and not setting selectedValue on dropdownlist. I have read some posts and they help but I am missing a crucial piece. My problem is that my dropdownlist is doubling the amount of records for the dropdownlist. Instead of "YES;NO;SELECT A VALUE", I am getting "YES;NO;SELECT A VALUE;YES;NO;YES;NO". My database is correct with the UPDATE part but the rebind after update is failing horribly.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            If Session("ACTIVETAB").ToString() = Session("SUBCONTRACTSATABNO").ToString() Then
            End If
        End If
    End Sub

    Public Function loadlookups(ByVal id As String, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) As DataTable
        Select Case id
            Case "ddlCertReceived"
                dt = GetLookupTable("SubcontractsA", "Sub 1 Cert Received")
                Dim ddlCertReceived As DropDownList = _
                CType(e.Item.FindControl("ddlCertReceived"), DropDownList)
                ddlCertReceived.DataSource = dt
                ddlCertReceived.DataTextField = "lup_text"

2 Databound Dropdownlists... how to bound data to the 2nd one?


hi there,
I have a database with the following table:

Table Job {
    nvarchar(50) JobID,
    nnarchar(50) JobName,
    Bit/Bool     Active;

I'm trying to build an .aspx page with two dropdownlists:

  1. The first will display the JobIDs of all Jobs available in the Database (I have done this part and it's working)
  2. The second will display by default the value "Choose Job first".

  What I'm trying to do is: Once the user chooses the JobID (step 1), the page should reload and the 2nd dropdownlist should display the following:

  •  if the value of the field "Active" of the corresponding JobID is '1'(i.e, the Job is already active) -> then the Dropdownlist should display "Already active" and "Deactivate" values
  • if the value of the field "Active" of the corresponding JobID is '0'(i.e, the Job is inactive) -> then the Dropdownlist should display "Activate" and "Already Deactive" values.

This is my code:


<div class="formField JobSelect">
<asp:Label ID="lbl_J

Detailsview clears filled in fields


I have a details view on my page that has a template field in it. In the template field is a button that when clicked, sets the visible property of another field to true. When this happens the whole detailsview resets and anything that was entered into other fiields is cleared. Is there any way to prevent the other fields from being cleared when the hidden field is set to be shown. 

Cascading Dropdown Question



I have 2 parent child cascading dropdowns on my form. At present they work as normal so you can only select a value from the second once you've selected one from the first, otherwise it's disabled. Is it possible to show all values in the second if you haven't selected anything from the first? Does that make sense?


what am i doing wrong with this objectdatasource that the DetailsView never gets populated


I want to allow the user to view and edit their information.

So using another example i found online, i got it work, but the example was setup for you to provide the user name and search for the person, since you are already logged into the system i want to pass your username into the code so that on page load the DetailView is populated with your details.

                      <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="UserName" DataSourceID="ObjectDataSource2" Width="400px">
                                <asp:BoundField DataField="PasswordQuestion" HeaderText="PasswordQuestion" ReadOnly="True" SortExpression="PasswordQuestion" />
                                <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />
                                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                <asp:BoundField DataField="CreationDate" HeaderText="CreationDate" ReadOnly="True" SortExpression="Cre

IP2003 cascading dropdowns w/SP2007

I'm new to IP.  My client base is IP2003 only on SP2007.  The forms have repeating data sections so web form is out of the question as I understand it. :(  

The forms are run on the clients local version off IP.  I would like to use a SharePoint list as the basis for some cascading drop downs.  Is that a realistic idea in IP as described? 

Weird problem in Detailsview - Dropdownlist in



I'm new in this forum and I really hope you'll be able to help me.

I converted a field in the detailsview into a template field and put a dropdownlist in the <InsertItemTemplate> and it worked great. This is the code I put:

<InsertItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre"  DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></InsertItemTemplate>

Now, I tried to do the same thing for the <EditItemTemplate> . This is the code I put there:

<EditItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre" DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></EditItemTemplate>  

When I change the DV properties I do see that a dropdownlist was  added but when I run the program and click on "Edit" in the DV nothing happens (however when I click on "Insert" it works fine).

This is the Select command for the data source I used:

<asp:SqlDataSource runat="server"

Ajax Cascading drop down method error 500!


Sorry to trouble you all with something that has already been posted a million times but I have tried everything I can and stuck with for about 10 days now. Please help. I have created 2 tables Categories, Subcategories.

Categories table has Category_ID(Primary Key) and "Category" fields. Subcat table has SubcatID(Primary Key, Sub_cat and Category_ID(Foreign Key). Here's the code of the asmx file.

Service methods used in ASPX file ServiceMethod="GetVendors" and ServiceMethod="GetContactsForVendor". Please help me find the source of the method erro 500 and I will be very greatful.

<%@ WebService Language="VB" Class="CascadingDropdown1" %>

Imports System.Web.Script.Services

Imports AjaxControlToolkit

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports System.Collections.Generic

Imports System.Collections.Specialized

Imports System.Data.SqlClient

<ScriptService()> _
Public Class CascadingDropdown1
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function GetVendors(ByVal knownCategoryValues As String, ByVal category As String) As Cascadi

How can I Set default value for drop down list filled with Cascading

Hi AllI've this problem, how can I set the default value for drop down list filled with cascading. I can't catch the event that came after cascading to set the default value and I can't call any control in this function:  "AjaxControlToolkit.CascadingDropDownNameValue[]"   I've passed the Drop down list as a session and the default value in session   When I call the session of "Drop Down List" the session value Is NULL in this function:  "AjaxControlToolkit.CascadingDropDownNameValue[]"   Any help please. 

How to return back back to code behind file after cascading dropdown calling

Hi, I have a cascading dropdown. After the dropdown is populated(it is in another file)  i would like to return back to the original form where the control is placed. is there anyway of doing it

DropDownLists and AutoPostBack

Hi,I have a web form with a number of DropDownLists on. The selection in each determines what data is displayed in the other lists, all of which data comes from a SQL server table. I've noticed that when I set AutoPostBack to true, the whole page refreshes when changing the selection within each list and I've also noticed that the values selected in the other lists are lost.Is there anyway which I can:1) Maintain values already selected across postbacks2) Stop the page refreshing each time a new item is selectedThanks in advance,Kev
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