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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:53:55+00:00 2026-06-04T04:53:55+00:00

Its my first time to encounter this problem so please anyone help me. Here’s

  • 0

Its my first time to encounter this problem so please anyone help me.
Here’s my problem I have 2 dropdownlist , the second one would be populated from the selected item in the first dropdownlist, and in the second dropdownlist it would populate the gridview depends on the chosen item. now the problem is, everytime I select any item from the 2nd ddl it posts back and the first item would be selected instead the item that I select.

heres my code: (aspx)

                   <asp:TableRow> <%--Branch--%>
                        <asp:TableCell HorizontalAlign="Left">
                            <asp:Label ID="lblBranch" runat="server" Font-Bold="true">Branch:</asp:Label>
                        </asp:TableCell>
                        <asp:TableCell HorizontalAlign="Left">
                            <asp:DropDownList ID="ddlBranch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlBranch_SelectedIndexChanged" AppendDataBoundItems="true" />
                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow> <%--Recepient--%>
                        <asp:TableCell HorizontalAlign="Left">
                            <asp:Label ID="lblRecepient" runat="server" Font-Bold="true">Recepient:</asp:Label>
                        </asp:TableCell>
                        <asp:TableCell HorizontalAlign="left">
                            <asp:DropDownList ID="ddlRecepientDepartment" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlRecepientDepartment_SelectedIndexChanged"  AppendDataBoundItems="true" EnableViewState="true"></asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow> <%--Gridview Recepient--%>
                        <asp:TableCell></asp:TableCell>
                        <asp:TableCell>
                            <asp:GridView ID="gvRecepientPosition" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                EmptyDataText="No Record found!" ShowFooter="false" ShowHeader="true" Width="99%" HorizontalAlign="Center" PageSize="5" OnPageIndexChanging="gvRecepientPosition_PageIndexChanging">
                                <Columns>
                                <%--<asp:TemplateField HeaderText="ID" Visible="false">
                                    <ItemTemplate>
                                    <asp:Label ID="lblID" runat="server" Text='<%# Bind("RECID") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>--%>
                                <asp:TemplateField HeaderText="Recepient" Visible="true">
                                     <ItemTemplate>
                                        <asp:CheckBox ID="cbRecepientPosition"  runat="server"/>
                                     </ItemTemplate>
                                </asp:TemplateField>
                                 <asp:BoundField DataField="Position" HeaderText="Position" ItemStyle-HorizontalAlign="Left" />
                                </Columns>
                            </asp:GridView>
                        </asp:TableCell>
                    </asp:TableRow>

CODE BEHIND:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ddlBranch.Items.Clear();
            GetBranch();

        }


    }

    private void GetBranch()
    {
             var objManager = new EmailNotificationInfoManager();
           // ddlBranch.Items.Clear();
            ddlBranch.DataSource = objManager.EmailNotificationInfoBranch();
            ddlBranch.DataTextField = "Branch";
            ddlBranch.DataValueField = "RECID";
            ddlBranch.DataBind();

            ddlBranch.Items.Insert(0,"<--Select-->");


    }

    protected void ddlBranch_SelectedIndexChanged(object sender, EventArgs e)
    {
        var objManager = new EmailNotificationInfoManager();
        ddlRecepientDepartment.Items.Clear();
        ddlRecepientDepartment.DataSource = objManager.EmailNotificationInfoDepartment(Convert.ToInt64(ddlBranch.SelectedValue));
        ddlRecepientDepartment.DataTextField = "Department";
        ddlRecepientDepartment.DataValueField = "branchID";
        ddlRecepientDepartment.DataBind();

        ddlRecepientDepartment.Items.Insert(0,"<--Select-->");

    }

    protected void ddlRecepientDepartment_SelectedIndexChanged(object sender, EventArgs e)
    {
        var objManager = new EmailNotificationInfoManager();

        gvRecepientPosition.DataSource = objManager.GetPositionByDepartment(ddlRecepientDepartment.SelectedItem.Text);
        gvRecepientPosition.DataBind();

        Session["PositionDepartment"] = objManager.GetPositionByDepartment(ddlRecepientDepartment.SelectedItem.Text);

        ddlRecepientDepartment.Attributes.Add("onChange", "this.currentvalue = this.value;");
        //Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
    }

PLEASE HELP ME WITH THIS ONE. THANK YOU!

  • 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-04T04:53:57+00:00Added an answer on June 4, 2026 at 4:53 am

    If you mean the first dropdown is getting the first item selected then check with the EnableViewState="true" property of ddlBranch

    And why this?

    ddlRecepientDepartment.Attributes.Add("onChange", "this.currentvalue = this.value;");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Somehow this is the first time I've ever encountered this problem in many years
I have this weird situation that i have encountered for the first time and
it s the first time i try this page. I ve just installed imagemagick
OK, so I'm working with a little regular expression—it's my first time, please, be
This is my first time working with file i/o in java, and it's not
Here's the problem. In my app, I have 5 tabs which contains activities. In
I have encountered this problem a few times, and am not able to figure
It's the first time I use java Rmi*. I have a custom class which
Its my first time working on a project in C. im just trying to
I encounter a problem of display with a webview i'm using in one of

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.