Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6802131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:11:08+00:00 2026-05-26T19:11:08+00:00

I have a DetailsView like this: <asp:DetailsView ID=detailsView1 runat=server DataSourceID=edsdetailsView AutoGenerateRows=False CssClass=pretty-table> <Fields> <asp:TemplateField

  • 0

I have a DetailsView like this:

<asp:DetailsView ID="detailsView1" runat="server"
    DataSourceID="edsdetailsView" AutoGenerateRows="False" CssClass="pretty-table">
    <Fields>
        <asp:TemplateField HeaderText="Cliente">
            <ItemTemplate>
                <asp:Label ID="dw1Label2" runat="server" Text='<%# Bind("Clienti.NomeSocieta") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="ddlClienti" runat="server" SelectedValue='<%# Bind("IDCliente") %>'
                    Width="300" DataSourceID="EntityDataSourceClienti" DataTextField="NomeSocieta"
                    AutoPostBack="true" DataValueField='IDCliente' 
                    onselectedindexchanged="ddlClienti_SelectedIndexChanged">
                </asp:DropDownList>
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:DropDownList ID="ddlClienti" runat="server" SelectedValue='<%# Bind("IDCliente") %>'
                    Width="300" DataSourceID="EntityDataSourceClienti" DataTextField="NomeSocieta"
                    AutoPostBack="true" DataValueField='IDCliente' 
                    onselectedindexchanged="ddlClienti_SelectedIndexChanged">
                </asp:DropDownList>
            </InsertItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Contatto" SortExpression="IDContatto">
            <ItemTemplate>
                <asp:Label ID="Label6" runat="server" Text='<%# Bind("Contatti.Nome") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList ID="ddlContatti" runat="server" SelectedValue='<%# Bind("IDContatto") %>'
                    Width="300px" DataSourceID="edsContatti" DataTextField="Nome"
                    DataValueField='IDContatto'>
                </asp:DropDownList>
             </EditItemTemplate>
             <InsertItemTemplate>
                 <asp:DropDownList ID="ddlContatti" runat="server" SelectedValue='<%# Bind("IDContatto") %>'
                     Width="300" DataSourceID="edsContatti" DataTextField="Nome"
                     DataValueField='IDContatto'/>
             </InsertItemTemplate>
         </asp:TemplateField>
    </Fields>
</asp:DetailsView>

it has a field named Cliente hooked up to an EntityDataSource:

<asp:EntityDataSource ID="EntityDataSourceClienti" runat="server" ConnectionString="name=SalesPortalEntities"
    DefaultContainerName="SalesPortalEntities" EnableFlattening="False" EntitySetName="Clienti"
    OrderBy="it.NomeSocieta" EntityTypeFilter="Clienti">
</asp:EntityDataSource>

and I’d like to change another field, Contatto, when I change the selection of the Cliente field. The EntityDataSource for Contatto is:

<asp:EntityDataSource ID="edsContatti" runat="server" ConnectionString="name=SalesPortalEntities"
    DefaultContainerName="SalesPortalEntities" EnableFlattening="False" EntitySetName="Contatti"
    Where="it.IDAzienda=@IDClienteFromDdl">
    <WhereParameters>
        <asp:Parameter Name="IDClienteFromDdl" Type="Int32"/>
    </WhereParameters>
</asp:EntityDataSource>

Also, for completeness this is the EntityDataSource for the DetailsView1:

<asp:EntityDataSource ID="edsdetailsView" runat="server" Include="Categorie,Commerciali,Clienti,Contatti"
    ConnectionString="name=SalesPortalEntities" OnInserting="UpdateDataSource" DefaultContainerName="SalesPortalEntities"
    EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True"
    EntitySetName="PianificazioneIncontri" Where="it.IDPianificazione = @IDPianificazione AND ((it.Obsoleto=false AND it.ApprovazioneModifica=false AND it.ApprovazioneEliminazione=false) OR (@GruppoAdmin='1' AND it.Obsoleto=false))"
    OnUpdating="edsdetailsView_Updating">
    <WhereParameters>
        <asp:ControlParameter ControlID="GridView1" Name="IDPianificazione" PropertyName="SelectedValue" Type="Int32" />
        <asp:Parameter Name="GruppoAdmin" Type="String" />
    </WhereParameters>
</asp:EntityDataSource>

the code-behind is:

protected void ddlClienti_SelectedIndexChanged(object sender, EventArgs e)
{
    edsContatti.WhereParameters[0].DefaultValue = ((DropDownList)sender).SelectedValue;        
}

How do I hook ddlContatti up to ddlClienti in DetailsView1‘s insert and edit modes?

Below is a screenshot of the details view:

enter image description here

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:11:09+00:00Added an answer on May 26, 2026 at 7:11 pm

    One more try here, and then I will quit wasting your time if this doesn’t work =)

    protected void ddlClienti_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        edsContatti.WhereParameters[0].DefaultValue = ((DropDownList)sender).SelectedValue;
        // Call DataBind to reload the DataSource based on the new WHERE clause
        edsContatti.DataBind();
        // Since you're using a DetailsView, you have to find the nested control within it
        DropDownList ddlContatti = (DropDownList)DetailsView1.FindControl("ddlConcatti");
        // And then call DataBind on it as well
        detailsView1.DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a control that look something like this: <asp:DetailsView ID=dvUsers runat=server DataSourceID=odsData DataKeyNames=Id>
<asp:DetailsView ID=DetailsView1 runat=server AutoGenerateRows=False DataSourceID=TimeEntriesDataSource RowStyle-VerticalAlign=Top DefaultMode=Insert HeaderStyle-HorizontalAlign=Center BackColor=White BorderColor=#336666 BorderStyle=Double BorderWidth=3px CellPadding=4 OnItemInserted=DetailsView1_ItemInserted
My problem is like this: In ASP DetailsView component we have three different EventArgs
Say you have something like an ASP.NET ASP:DetailsView to show and edit a single
I currently have a DetailsView in ASP.NET that gets data from the database based
I have this int I am declaring in my .h file like this: @interface
I am trying to learn ASP.NET MVC and I hit this problem: I have
I have a asp.net page I'm writing and I'm perplexed by this problem. I
This is kind of silly but I have a DetailsView that binds to a
i have an aspx-page which contains a detailsview. this detailsview contains one or more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.