Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Hey, I am unable to get the selected value of the DropDownList in Ajax Toolkit Modal Popup Extender

$
0
0

Hey,

I am unable to get the selected value of the DropDownList.  When the user selects a value and clicks Save, the value that was loaded as the default selected value with an index of 0 is available in code behind, not the newly selected value.  See the attached code for the dropdownlist in the Modal Popup form.  Thanks

<asp:Panel ID="PanelAddState" runat="server" Width="80%" BorderColor="Green" BorderStyle="Outset" BorderWidth="5" BackColor="SlateBlue"><asp:Panel ID="PanelAddStateTitle" runat="server" Width="100%" HorizontalAlign="Center" style="cursor:move;display:none"><b> Add State Details</b></asp:Panel><table style="width:100%;margin:5px;border:2px solid blue"><tr><td>
                    Country Name</td><td>:</td><td><asp:DropDownList ID="ddlAddCountry" runat="server"></asp:DropDownList></td></tr><tr><td align="left" width="25%">
                State Name</td><td width="2%">
                    :</td><td><asp:TextBox ID="txtAddStateName" runat="server" placeHolder="Enter Country Name"></asp:TextBox><asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="txtAddStateName" ErrorMessage="Require State Name"  ValidationGroup="Add" ></asp:RequiredFieldValidator><ajaxToolkit:ValidatorCalloutExtender ID="vce1" runat="server" TargetControlID="rfv1" Width="300"></ajaxToolkit:ValidatorCalloutExtender> </td></tr><tr><td align="left">
                    Is Active</td><td>:</td><td><asp:CheckBox ID="chkAddIsActive" runat="server" /></td></tr><tr><td></td><td></td><td><asp:Button ID="btnSave" runat="server"  ValidationGroup="Add" Text="Save" OnClick="btnSave_Click" /> &nbsp;<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" /></td></tr></table></asp:Panel><ajaxToolkit:ModalPopupExtender ID="mpe1" runat="server" TargetControlID="btnNew" PopupControlID="PanelAddState" PopupDragHandleControlID="PanelAddStateTitle" DropShadow="true" RepositionMode="RepositionOnWindowResizeAndScroll" CancelControlID="btnCancel" BackgroundCssClass="modelPoupBackground" OnLoad="mpe1_Load"  ></ajaxToolkit:ModalPopupExtender>
protected void btnSave_Click(object sender, EventArgs e)
    {
        State obj = new State();
            obj.CountryId = Convert.ToInt32(ddlAddCountry.SelectedValue);
        obj.StateName = txtAddStateName.Text.Trim();
        obj.IsActive = chkAddIsActive.Checked;
        if (obj.AddState() > 0)
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "Message", "<script>alert('State Details Added Successfully')</script>");
            BindData();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "Message", "<script>alert('State Details Adding Failed')</script>");
        }
        txtAddStateName.Text = string.Empty;
        chkAddIsActive.Checked = false;
    }


//State Class Code


public int AddState()
        {
            sqlCommandText = "SP_AddState";
            Database defaultDB = Connection.GetDefaultDbConnection();
            DbCommand dbCommand = defaultDB.GetStoredProcCommand(sqlCommandText);
            defaultDB.AddInParameter(dbCommand, "CountryId", DbType.Int32,CountryId);
            defaultDB.AddInParameter(dbCommand, "StateName", DbType.String, _StateName);
            defaultDB.AddInParameter(dbCommand, "IsActive", DbType.Boolean, _IsActiveState);
            return defaultDB.ExecuteNonQuery(dbCommand);

        }




Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>