触发主页按钮单击事件时,将数据绑定到gridview [英] bindig data to gridview when master page button click event fired
本文介绍了触发主页按钮单击事件时,将数据绑定到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在主页按钮点击事件被激活时将数据绑定到内容页面的gridview。我在内容页面中处理主页按钮点击事件...请帮助我...(语言是C#)
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#)
推荐答案
试试这个。
Hi,
try this.
<![CDATA[<%-- master page button --%>
<asp:button id="btn" runat="server" text="Bind" />
// 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.
Hai,
请参考此链接 http://love2dev.com/#!article/Handling-Master-Page-Click-Events-in-the-Content-Page [ ^ ]
Hi Tun
试试这样吧,
创建一个方法要绑定网格的内容页面(例如:ContentPageMethod()
)。并使用Reflection
调用母版页中的方法。
以下是我的参考代码
内容页面:
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 usingReflection
.
Below is my code for reference
Content Page :
public void ContentPageMethod()
{
GridView1.DataSource = Enumerable.Range(0, 10);
GridView1.DataBind();
}
母版页:
Master Page :
protected void MasterPageButton_Click(object sender, EventArgs e)
{
this.Page.GetType().GetMethod("ContentPageMethod").Invoke(this.Page, null);
}
这篇关于触发主页按钮单击事件时,将数据绑定到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文