从主页面选择内容页面gridview,不带查询字符串 [英] select content page gridview from master page without querystring
问题描述
你好朋友
我的主页上有文本框和按钮.
在内容页面中,我有gridview项.
我想在grodview中显示文本框数据而不使用querystring
注意:文本框和表格视图不在同一页面.
主页上的文本框.
内容页面中的Gridview.
这可能吗?
请帮帮我.
在此先感谢.
这是解决方案
首先从MasterPage获取TextBox的访问权限
Textbox txt1 = (TextBox)MasterPage.FindControl("txt1");
通过使用此功能,您可以获取Textbox的价值
-> txt1.子页面中的文本
现在,您可以在GridView中显示此值
尝试这个 .我正在使用它并且有效
在内容页面中,页面加载访问主页面控件.
Page.Master.FindControl("Master_Page_ControlID").//您要执行的操作.假设我们的母版页文本框ID为 txt_masterpage
而您想获取此文本框的文本,则可以编写为
字符串str_result = Page.Master.FindControl("txt_masterpage").Text;
希望这会对您有所帮助.
嘿,不要在PAge_Load事件内使用此代码
TextBox txt = (TextBox)Master.FindControl("TextBox1");
或执行其他操作在内容页面中再放置一个按钮
并在button_Click事件内部使用此代码
它将起作用...
Hello Friends
I am having text box and button in masterpage.
In content page I m having gridview item.
I want to show textbox data in grodview without usingquerystring
Note:text box and gridview are not in same page.
Text box in masterpage.
Gridview in content page.
Is this possible.
Please help me.
Thanks in Advance.解决方案Here is the Solution
First Get the access of TextBox from MasterPage
Textbox txt1 = (TextBox)MasterPage.FindControl("txt1");
By Using this you can get value of Textbox
--> txt1.Text in Child Page
Now you can display this value inside GridView
Hi,
Try this . I am using this and it works
In your content pages page load access master pags control.
Page.Master.FindControl("Master_Page_ControlID").//Operation you want to perform. Suppose our master page text box id is txt_masterpage
and you want to take text of this textbox then you can write as
string str_result = Page.Master.FindControl("txt_masterpage").Text;
Hope this will help you.
Hey Don''t Use this code inside PAge_Load Event
TextBox txt = (TextBox)Master.FindControl("TextBox1");
Or Else Do One thing place one more button in content page
and inside button_Click Event Use this Code
It will work...
这篇关于从主页面选择内容页面gridview,不带查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!