none
How to prevent postback in dropdownlist selectedIndexChanged RRS feed

  • Question

  • Hi,

    I have a dropdownlist in side a gridview, Onselectedindexchanged I want to some action. But it doing postback but I don't want postback.Can any one helpme out in stoping the PostBack.I also used Updatepanel but after that the action what I want its not happening.

    Below is my code for .cs

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
    
                if (this.UserContext.UserRoles.Length == 0)
                {
                    Response.Redirect("./Default.aspx");
                }
                if (!IsUserInRole(Constants.RL_GETSSET))
                {
                    Response.Redirect("./Default.aspx");
                }
    
                adminBO = new UpdateAdminBO(this.UserContext);
                btnRemove.Visible = false;
                listSupportRoles = new DomainByCodeValue(this.UserContext, CategotyCode.SUPPORT_ROLES).DomainCodeValue;
                listClarifyRegions = new DomainByCodeValue(this.UserContext, CategotyCode.CLARIFY_REGION).DomainCodeValue;
                ViewState["listClarifyRegions"] = listClarifyRegions;
                existingUserDetails = adminBO.GetUserDetails();
                // Selected Option.
                // Q4 Requirements
                if (!IsPostBack)
                {
                    ddlUserRoleSelect.DataSource = listSupportRoles;
                    ddlUserRoleSelect.DataTextField = "CodeValue";
                    ddlUserRoleSelect.DataValueField = "CodeID";
                    ddlUserRoleSelect.DataBind();
                    ddlUserRoleSelect.Items.Insert(0, new ListItem("ALL", "1"));
                    this.BindData();
    
                    ddlAddUser.DataSource = listSupportRoles;
                    ddlAddUser.DataTextField = "CodeValue";
                    ddlAddUser.DataValueField = "CodeID";
                    ddlAddUser.DataBind();
                    ddlAddUser.Items.Insert(0, new ListItem("Select User Role", "1"));
    
                    rcbRegions.DataSource = ViewState["listClarifyRegions"];
                    rcbRegions.DataTextField = "CodeValue";
                    rcbRegions.DataValueField = "CodeID";
                    rcbRegions.DataBind();
    
    
                    ddlUserRole.DataSource = listSupportRoles;
                    ddlUserRole.DataTextField = "CodeValue";
                    ddlUserRole.DataValueField = "CodeID";
                    ddlUserRole.DataBind();
                    ddlUserRole.Items.Insert(0, new ListItem("ALL", "1"));
    
                    //V-sisann Removed Code.
                    if (Request.QueryString["id"] != null)
                    {
                        ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
                        ScriptManager.RegisterClientScriptBlock(BtnUpdate, Page.GetType(), "MsgType_Info", "doShowMsg(\"New User Updated successfully.\", MsgType_Info)", true);
                    }
                }
            }
        }

    protected void ddlUserRole_SelectedIndexChanged(object sender, EventArgs e)
        {
    
            //get user role drop down list
            DropDownList ddlRole = (DropDownList)sender;
    
            //get selected userrole row
            GridViewRow row = (GridViewRow)ddlRole.NamingContainer;
    
            ////get inner grid
            //GridView gridInner = (GridView)row.NamingContainer;
    
            ////get user detials grid
            //GridView gridUserDetails = (GridView)gridInner.NamingContainer;
    
            //System.Web.UI.HtmlControls.HtmlImage img = (HtmlImage)gridUserDetails.NamingContainer.FindControl("imgDetail");
    
            Telerik.Web.UI.RadComboBox rcbSecondaryUserRole = row.FindControl("rcbSecondaryUserRole") as RadComboBox;
    
            if (ddlRole.SelectedItem.Text == "GSPO")
            {
                rcbSecondaryUserRole.DataSource = ViewState["listClarifyRegions"];
                rcbSecondaryUserRole.DataTextField = "CodeValue";
                rcbSecondaryUserRole.DataValueField = "CodeID";
                rcbSecondaryUserRole.DataBind();
                rcbSecondaryUserRole.Visible = true;
            }   
            else
            {
                rcbSecondaryUserRole.Visible = false;
            }
        }

    Wednesday, April 24, 2013 2:24 PM

Answers

All replies