Click here to Skip to main content
15,909,590 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i want to bind data to content page's gridview when master page button click event fired.how do i handle master page button click event in content page...please help me...(language is C#)
Posted
Comments
What have you tried and where is the problem?

Hi,
try this.
ASP
<![CDATA[<%-- master page button --%>
<asp:button id="btn" runat="server" text="Bind" />

C#
// content page
protected void Page_Load(object sender, EventArgs e)
{
    // add button click event handler in content page
    Button btn = (Button)this.Master.FindControl("btn");
    btn.Click+=new EventHandler(btn_Click);
}

protected void btn_Click(object sender, EventArgs e)
{
    // grid binding code.     
}

Hope it helps you.
Thanks.
 
Share this answer
 
v3
 
Share this answer
 
v2
Hi Tun

Try like this,,

Create a method in the content page ( ex : ContentPageMethod() ) where you want to bind the grid. and invoke the method in master page using Reflection.

Below is my code for reference


Content Page :
C#
public void ContentPageMethod()
       {
           GridView1.DataSource = Enumerable.Range(0, 10);
           GridView1.DataBind();
       }


Master Page :
C#
protected void MasterPageButton_Click(object sender, EventArgs e)
        {
            this.Page.GetType().GetMethod("ContentPageMethod").Invoke(this.Page, null);
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900