Vedank Kulshrestha
Vedank Kulshrestha

Reputation: 220

How to Save Data without Page Reloading on Dropdown SelectedIndexChanged Event

I am trying to update a DataTable on selection Index Changed event of DropdownList.

What I want is when I select/change dropDownList Item, the Selected Value should be saved into the database without Page refresh(without AutoPostback).

Upvotes: 0

Views: 1622

Answers (1)

nunespascal
nunespascal

Reputation: 17724

You will need to set AutoPostback to true.
But you can use an update panel to do a partial PostBack and not refresh the complete page.

See here

Use it like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" >      
  <ContentTemplate>
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"  onselectedindexchanged="DropDownList1_SelectedIndexChanged">
      <asp:ListItem>item 1</asp:ListItem>
      <asp:ListItem>item 2</asp:ListItem>
    </asp:DropDownList>
  </ContentTemplate>
</asp:UpdatePanel>

Upvotes: 1

Related Questions