0
Answer

Unable to cast Object of type ‘ASP.MasterPage_Master’ to type ‘ASP.MasterPage_Master’

I am facing this problem

 

Unable to cast Object of type ‘ASP.MasterPage_Master’ to type ‘ASP.MasterPage_Master’

 

We use the master page with the drop down list. The value of the dropdown list is used in the content page. The developed code for this scenario is given below.

 

Main.Master.cs

 

public event CommandEventHandler SelectedIndexChangedForDDL;

 

protected void cmbActionType_SelectedIndexChanged(object sender, EventArgs e)

    {

        if (SelectedIndexChangedForDDL != null)

            SelectedIndexChangedForDDL(this, new CommandEventArgs(cmbActionType.ClientID, cmbActionType.SelectedItem.Value.ToString()));

    }

 

 

 

Home.aspx

 

 

protected void Page_Load(object sender, EventArgs e)

{

 // Command Event SelectedIndexChangedForDDL Handler is declared in

 // Main.Master Page.

Master.SelectedIndexChangedForDDL += new

 

CommandEventHandler(GetIndex);

      

}

 

private void GetIndex(object sender, CommandEventArgs e)

{

 

if (sender != null)

   {

 

if((e.CommandArgument.ToString() == null)||

 

 e.CommandArgument.ToString() == "")

                {

 

                    PopulateDataGrid();

                }

                else

                {

                    PopulateDataGridBasedOnDropDownSelection(Int32.Parse(e.CommandArgument.ToString()));

                }

     }

  }