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 9050977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:47:25+00:00 2026-06-16T12:47:25+00:00

Let’s say, I have a Listview control on the page. Each Listview item has

  • 0

Let’s say, I have a Listview control on the page. Each Listview item has 2 dropdownlists and 1 textbox. When the first dropdownlist has a selected value changed, the second dropdownlist should be populated with city depending on the first one. Finaly, when a value is selected for the second dropdownlist, a cost should appear on the textbox.

<asp:ListView ID="_lsvCostFinder" runat="server">
    <LayoutTemplate>
        <table>
            <tr>
                <th>Country</th>
                <th>City</th>
                <th>Cost</th>
            </tr>
            <tr  runat="server" id="itemPlaceHolder">
            </tr>
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:DropDownList ID="_ddlCountry" runat="server" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack = "true">
                </asp:DropDownList>
            </td>
            <td>
                <asp:DropDownList ID="_ddlCity" runat="server" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged" AutoPostBack = "true">
                </asp:DropDownList>
            </td>
            <td>
                <asp:TextBox ID="_txtCost" runat="server"></asp:TextBox>
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>

Now I want to use ajax when user selects a different value for the dropdownlist

$('select').change(function () {
   $.ajax({
  type: "POST",
  url: "Default.aspx/DropDownList1_SelectedIndexChanged",
  data: "{}",
  success: function(msg) {
    // Replace the div's content with the page method's return.
    //
  }
 });

I want to replace only the entire tr element. Those are my questions:

  1. What should I send in the data? The value of the dropdownlist?

  2. How do I replace only the row containing the dropdownlist that triggered the ajax call?

EDIT

All the methods have the following signature

protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)

It’s a very long and complex page.

Thanks for helping

  • 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-06-16T12:47:26+00:00Added an answer on June 16, 2026 at 12:47 pm

    Firstly, looking at the sample code you posted and how you plan to make the Ajax call, you will need to enable PageMethods in your page. See this tutorial on how to do that part.

    The actual ajax call using jQuery can be as simple as this:

    $('select').change(function () {
         $.post('Default.aspx/MethodName',{selectedVal:$(this).val()}, function(data){
             //as far as placing the result in the input text field, I think this will do:
             $(this).parents('tr').find('input:text').val(data);
         });
    });
    

    Now, your MethodName method would have to look like this:

      [WebMethod]
      public static string MethodName(string selectedVal)
      {
         return "something";
      }
    

    jsfiddle (minus the ajax call).

    Update

    Sorry, I misread the question, the OP wants to replace the WHOLE row. This will do then:

     $(this).parents('tr').replaceWith('<tr><td colspan="3"><div>'+data+'</div></td></tr>');
    

    Full context:

    $('select').change(function () {
             $.post('Default.aspx/MethodName',{selectedVal:$(this).val()}, function(data){
                 //as far as replacing the row, this will do:
                   $(this).parents('tr').replaceWith('<tr><td colspan="3"><div>'+$(this).val()+'</div></td></tr>');
             });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say my section contains the pages Red, Green and Blue. Each page has
Let's say I have one class User, and it has a property of type
Let's say you have a class library project that has any number of supplemental
Let's say that each Product has a category. I want to ask the Users
Let's say I have a Job Scheduler which has 4 consumers A, B, C
Let's say I have two objects, Master and Slave . Slave has a method
Let's say I have two assemblies: BusinessLogic and Web. BusinessLogic has an application setting
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can

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.