Hi folks
I have a "Search" text box and LinkButton in my master page. When this is
submitted, I do a Server.Transfer to a page which contains a gridview. The
gridview is filtered on a hidden field which I set in the page load method
(from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a
record in the gridview to populate a DetailsView, I loose the original
filter and so the returned page just contains an un-filtered grid view. When
I put a breakpoint on page load I can see that the search text box is
cleared and doesn't seem to keep it's value between this call and the last
one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the
Server.Transfer , but I need to do this to get me onto the right page (since
the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will 8 1424
in your page load event are you checking for a "postback". .
e.g.
if not ispostback=true then
txtHiddenField. text="xyz"
end if
"William Buchanan" wrote: Hi folks
I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden field which I set in the page load method (from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a record in the gridview to populate a DetailsView, I loose the original filter and so the returned page just contains an un-filtered grid view. When I put a breakpoint on page load I can see that the search text box is cleared and doesn't seem to keep it's value between this call and the last one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the Server.Transfer , but I need to do this to get me onto the right page (since the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will
Thanks for the really quick reply!!!
Here's my page load event..... gvAdList is the gridview and hfSearch is the
hidden field. The grid view is fed from an objectdatasourc e - I have added
it's code at the bottom:
protected void Page_Load(objec t sender, EventArgs e)
{
gvAdList.PageSi ze = (int)Session["GridPageSi ze"];
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";
if (PreviousPage != null)
frm = PreviousPage.Fo rm;
else if (Master != null)
frm = Form;
if (frm != null)
try
{
tb = (TextBox)frm.Fi ndControl("tbMa inSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }
hfSearch.Value = sQry;
}
<asp:ObjectData Source ID="odsAdList" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etData"
TypeName="direc tory.data.DS_Di rectoryTableAda pters.vwAdvertL istTableAdapter "
FilterExpressio n="CompanyNam e like '%{0}%' or Descr like '%{0}%'">
<FilterParamete rs>
<asp:ControlPar ameter ControlID="hfSe arch" Name="CompanyNa me"
PropertyName="V alue"
Size="150" Type="String" />
</FilterParameter s>
</asp:ObjectDataS ource>
"NH" <NH@discussions .microsoft.com> wrote in message
news:69******** *************** ***********@mic rosoft.com... in your page load event are you checking for a "postback". .
e.g.
if not ispostback=true then txtHiddenField. text="xyz" end if
"William Buchanan" wrote:
Hi folks
I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden field which I set in the page load method (from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a record in the gridview to populate a DetailsView, I loose the original filter and so the returned page just contains an un-filtered grid view. When I put a breakpoint on page load I can see that the search text box is cleared and doesn't seem to keep it's value between this call and the last one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the Server.Transfer , but I need to do this to get me onto the right page (since the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will
try this...
protected void Page_Load(objec t sender, EventArgs e)
{
gvAdList.PageSi ze = (int)Session["GridPageSi ze"];
if not ispostback=true then 'Change this to whatever the C# syntax is..
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";
if (PreviousPage != null)
frm = PreviousPage.Fo rm;
else if (Master != null)
frm = Form;
if (frm != null)
try
{
tb = (TextBox)frm.Fi ndControl("tbMa inSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }
hfSearch.Value = sQry;
end if
}
"William Buchanan" wrote: Thanks for the really quick reply!!!
Here's my page load event..... gvAdList is the gridview and hfSearch is the hidden field. The grid view is fed from an objectdatasourc e - I have added it's code at the bottom:
protected void Page_Load(objec t sender, EventArgs e) { gvAdList.PageSi ze = (int)Session["GridPageSi ze"]; TextBox tb = null; HtmlForm frm = null; string sQry = "";
if (PreviousPage != null) frm = PreviousPage.Fo rm; else if (Master != null) frm = Form;
if (frm != null) try { tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); if (tb != null) sQry = tb.Text; } catch { }
hfSearch.Value = sQry; }
<asp:ObjectData Source ID="odsAdList" runat="server" OldValuesParame terFormatString ="original_{ 0}" SelectMethod="G etData" TypeName="direc tory.data.DS_Di rectoryTableAda pters.vwAdvertL istTableAdapter " FilterExpressio n="CompanyNam e like '%{0}%' or Descr like '%{0}%'"> <FilterParamete rs> <asp:ControlPar ameter ControlID="hfSe arch" Name="CompanyNa me" PropertyName="V alue" Size="150" Type="String" /> </FilterParameter s> </asp:ObjectDataS ource>
"NH" <NH@discussions .microsoft.com> wrote in message news:69******** *************** ***********@mic rosoft.com... in your page load event are you checking for a "postback". .
e.g.
if not ispostback=true then txtHiddenField. text="xyz" end if
"William Buchanan" wrote:
Hi folks
I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden field which I set in the page load method (from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a record in the gridview to populate a DetailsView, I loose the original filter and so the returned page just contains an un-filtered grid view. When I put a breakpoint on page load I can see that the search text box is cleared and doesn't seem to keep it's value between this call and the last one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the Server.Transfer , but I need to do this to get me onto the right page (since the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will
Hi
Thanks again.
I have tried this... the problem is, what happens when it is a postback?
Since the search box is on all pages (including the gridview page) I need to
catch postbacks as well.
Adding this code has however fixed the problem of the search text box
loosing it's value.
How can I get around this?
"NH" <NH@discussions .microsoft.com> wrote in message
news:82******** *************** ***********@mic rosoft.com... try this...
protected void Page_Load(objec t sender, EventArgs e) { gvAdList.PageSi ze = (int)Session["GridPageSi ze"];
if not ispostback=true then 'Change this to whatever the C# syntax is.. TextBox tb = null; HtmlForm frm = null; string sQry = "";
if (PreviousPage != null) frm = PreviousPage.Fo rm; else if (Master != null) frm = Form;
if (frm != null) try { tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); if (tb != null) sQry = tb.Text; } catch { }
hfSearch.Value = sQry;
end if }
"William Buchanan" wrote:
Thanks for the really quick reply!!!
Here's my page load event..... gvAdList is the gridview and hfSearch is the hidden field. The grid view is fed from an objectdatasourc e - I have added it's code at the bottom:
protected void Page_Load(objec t sender, EventArgs e) { gvAdList.PageSi ze = (int)Session["GridPageSi ze"]; TextBox tb = null; HtmlForm frm = null; string sQry = "";
if (PreviousPage != null) frm = PreviousPage.Fo rm; else if (Master != null) frm = Form;
if (frm != null) try { tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); if (tb != null) sQry = tb.Text; } catch { }
hfSearch.Value = sQry; }
<asp:ObjectData Source ID="odsAdList" runat="server" OldValuesParame terFormatString ="original_{ 0}" SelectMethod="G etData" TypeName="direc tory.data.DS_Di rectoryTableAda pters.vwAdvertL istTableAdapter " FilterExpressio n="CompanyNam e like '%{0}%' or Descr like '%{0}%'"> <FilterParamete rs> <asp:ControlPar ameter ControlID="hfSe arch" Name="CompanyNa me" PropertyName="V alue" Size="150" Type="String" /> </FilterParameter s> </asp:ObjectDataS ource>
"NH" <NH@discussions .microsoft.com> wrote in message news:69******** *************** ***********@mic rosoft.com... > in your page load event are you checking for a "postback". . > > e.g. > > if not ispostback=true then > txtHiddenField. text="xyz" > end if > > "William Buchanan" wrote: > >> Hi folks >> >> I have a "Search" text box and LinkButton in my master page. When this >> is >> submitted, I do a Server.Transfer to a page which contains a gridview. >> The >> gridview is filtered on a hidden field which I set in the page load >> method >> (from the search text box text). >> >> Now, the grid view appears to filter correctly, however, when I select >> a >> record in the gridview to populate a DetailsView, I loose the original >> filter and so the returned page just contains an un-filtered grid >> view. >> When >> I put a breakpoint on page load I can see that the search text box is >> cleared and doesn't seem to keep it's value between this call and the >> last >> one. I have got ViewState turned on. >> >> Any ideas how I can get around this? I guess it is something to do >> with >> the >> Server.Transfer , but I need to do this to get me onto the right page >> (since >> the text box doesn't have a postbackurl - (or is it the link button)). >> >> Thanks >> >> Will >> >> >>
try moving the "if not ispostback=true then 'Change this to whatever the C#
syntax is.." to just above the line " if (frm != null)"
"William Buchanan" wrote: Hi
Thanks again.
I have tried this... the problem is, what happens when it is a postback? Since the search box is on all pages (including the gridview page) I need to catch postbacks as well.
Adding this code has however fixed the problem of the search text box loosing it's value.
How can I get around this?
"NH" <NH@discussions .microsoft.com> wrote in message news:82******** *************** ***********@mic rosoft.com... try this...
protected void Page_Load(objec t sender, EventArgs e) { gvAdList.PageSi ze = (int)Session["GridPageSi ze"];
if not ispostback=true then 'Change this to whatever the C# syntax is.. TextBox tb = null; HtmlForm frm = null; string sQry = "";
if (PreviousPage != null) frm = PreviousPage.Fo rm; else if (Master != null) frm = Form;
if (frm != null) try { tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); if (tb != null) sQry = tb.Text; } catch { }
hfSearch.Value = sQry;
end if }
"William Buchanan" wrote:
Thanks for the really quick reply!!!
Here's my page load event..... gvAdList is the gridview and hfSearch is the hidden field. The grid view is fed from an objectdatasourc e - I have added it's code at the bottom:
protected void Page_Load(objec t sender, EventArgs e) { gvAdList.PageSi ze = (int)Session["GridPageSi ze"]; TextBox tb = null; HtmlForm frm = null; string sQry = "";
if (PreviousPage != null) frm = PreviousPage.Fo rm; else if (Master != null) frm = Form;
if (frm != null) try { tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); if (tb != null) sQry = tb.Text; } catch { }
hfSearch.Value = sQry; }
<asp:ObjectData Source ID="odsAdList" runat="server" OldValuesParame terFormatString ="original_{ 0}" SelectMethod="G etData" TypeName="direc tory.data.DS_Di rectoryTableAda pters.vwAdvertL istTableAdapter " FilterExpressio n="CompanyNam e like '%{0}%' or Descr like '%{0}%'"> <FilterParamete rs> <asp:ControlPar ameter ControlID="hfSe arch" Name="CompanyNa me" PropertyName="V alue" Size="150" Type="String" /> </FilterParameter s> </asp:ObjectDataS ource>
"NH" <NH@discussions .microsoft.com> wrote in message news:69******** *************** ***********@mic rosoft.com... > in your page load event are you checking for a "postback". . > > e.g. > > if not ispostback=true then > txtHiddenField. text="xyz" > end if > > "William Buchanan" wrote: > >> Hi folks >> >> I have a "Search" text box and LinkButton in my master page. When this >> is >> submitted, I do a Server.Transfer to a page which contains a gridview. >> The >> gridview is filtered on a hidden field which I set in the page load >> method >> (from the search text box text). >> >> Now, the grid view appears to filter correctly, however, when I select >> a >> record in the gridview to populate a DetailsView, I loose the original >> filter and so the returned page just contains an un-filtered grid >> view. >> When >> I put a breakpoint on page load I can see that the search text box is >> cleared and doesn't seem to keep it's value between this call and the >> last >> one. I have got ViewState turned on. >> >> Any ideas how I can get around this? I guess it is something to do >> with >> the >> Server.Transfer , but I need to do this to get me onto the right page >> (since >> the text box doesn't have a postbackurl - (or is it the link button)). >> >> Thanks >> >> Will >> >> >>
Hi
Thanks again.
I did try it, but it didn't work. The thing is there is nothing in that code
which clears the text box, or the value, so the mystery seems to be that
this is being lost somewhere.
Will
"NH" <NH@discussions .microsoft.com> wrote in message
news:5C******** *************** ***********@mic rosoft.com... try moving the "if not ispostback=true then 'Change this to whatever the C# syntax is.." to just above the line " if (frm != null)"
"William Buchanan" wrote:
Hi
Thanks again.
I have tried this... the problem is, what happens when it is a postback? Since the search box is on all pages (including the gridview page) I need to catch postbacks as well.
Adding this code has however fixed the problem of the search text box loosing it's value.
How can I get around this?
"NH" <NH@discussions .microsoft.com> wrote in message news:82******** *************** ***********@mic rosoft.com... > try this... > > protected void Page_Load(objec t sender, EventArgs e) > { > gvAdList.PageSi ze = (int)Session["GridPageSi ze"]; > > if not ispostback=true then 'Change this to whatever the C# syntax is.. > TextBox tb = null; > HtmlForm frm = null; > string sQry = ""; > > if (PreviousPage != null) > frm = PreviousPage.Fo rm; > else if (Master != null) > frm = Form; > > if (frm != null) > try > { > tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); > if (tb != null) > sQry = tb.Text; > } > catch { } > > hfSearch.Value = sQry; > > end if > } > > > "William Buchanan" wrote: > >> Thanks for the really quick reply!!! >> >> Here's my page load event..... gvAdList is the gridview and hfSearch >> is >> the >> hidden field. The grid view is fed from an objectdatasourc e - I have >> added >> it's code at the bottom: >> >> protected void Page_Load(objec t sender, EventArgs e) >> { >> gvAdList.PageSi ze = (int)Session["GridPageSi ze"]; >> TextBox tb = null; >> HtmlForm frm = null; >> string sQry = ""; >> >> if (PreviousPage != null) >> frm = PreviousPage.Fo rm; >> else if (Master != null) >> frm = Form; >> >> if (frm != null) >> try >> { >> tb = (TextBox)frm.Fi ndControl("tbMa inSearch"); >> if (tb != null) >> sQry = tb.Text; >> } >> catch { } >> >> hfSearch.Value = sQry; >> } >> >> >> <asp:ObjectData Source ID="odsAdList" runat="server" >> OldValuesParame terFormatString ="original_{ 0}" >> SelectMethod="G etData" >> TypeName="direc tory.data.DS_Di rectoryTableAda pters.vwAdvertL istTableAdapter " >> FilterExpressio n="CompanyNam e like '%{0}%' or Descr like '%{0}%'"> >> <FilterParamete rs> >> <asp:ControlPar ameter ControlID="hfSe arch" >> Name="CompanyNa me" >> PropertyName="V alue" >> Size="150" Type="String" /> >> </FilterParameter s> >> </asp:ObjectDataS ource> >> >> "NH" <NH@discussions .microsoft.com> wrote in message >> news:69******** *************** ***********@mic rosoft.com... >> > in your page load event are you checking for a "postback". . >> > >> > e.g. >> > >> > if not ispostback=true then >> > txtHiddenField. text="xyz" >> > end if >> > >> > "William Buchanan" wrote: >> > >> >> Hi folks >> >> >> >> I have a "Search" text box and LinkButton in my master page. When >> >> this >> >> is >> >> submitted, I do a Server.Transfer to a page which contains a >> >> gridview. >> >> The >> >> gridview is filtered on a hidden field which I set in the page load >> >> method >> >> (from the search text box text). >> >> >> >> Now, the grid view appears to filter correctly, however, when I >> >> select >> >> a >> >> record in the gridview to populate a DetailsView, I loose the >> >> original >> >> filter and so the returned page just contains an un-filtered grid >> >> view. >> >> When >> >> I put a breakpoint on page load I can see that the search text box >> >> is >> >> cleared and doesn't seem to keep it's value between this call and >> >> the >> >> last >> >> one. I have got ViewState turned on. >> >> >> >> Any ideas how I can get around this? I guess it is something to do >> >> with >> >> the >> >> Server.Transfer , but I need to do this to get me onto the right >> >> page >> >> (since >> >> the text box doesn't have a postbackurl - (or is it the link >> >> button)). >> >> >> >> Thanks >> >> >> >> Will >> >> >> >> >> >> >> >> >>
How are you storing the text in a hidden field? Are you sure that this field
is getting re-created on the page that you are Server.Transfer 'ring to?
"William Buchanan" <william.buchan an@naespam_free net.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. .. Hi folks
I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden field which I set in the page load method (from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a record in the gridview to populate a DetailsView, I loose the original filter and so the returned page just contains an un-filtered grid view. When I put a breakpoint on page load I can see that the search text box is cleared and doesn't seem to keep it's value between this call and the last one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the Server.Transfer , but I need to do this to get me onto the right page (since the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will
Hi Sol
The hidden field was dragged onto the page from the toolbox. I populate it
in the page load method:
hfSearch.Value = sQry; // sQry is the contents of the text box
When debugging I can see the hidden field being populated correctly.... the
issues seems to be that the text box looses it's value.
Thanks
Will
"Sol" <so*@newsgroups .nospam> wrote in message
news:up******** ******@TK2MSFTN GP03.phx.gbl... How are you storing the text in a hidden field? Are you sure that this field is getting re-created on the page that you are Server.Transfer 'ring to?
"William Buchanan" <william.buchan an@naespam_free net.co.uk> wrote in message news:%2******** ********@TK2MSF TNGP04.phx.gbl. .. Hi folks
I have a "Search" text box and LinkButton in my master page. When this is submitted, I do a Server.Transfer to a page which contains a gridview. The gridview is filtered on a hidden field which I set in the page load method (from the search text box text).
Now, the grid view appears to filter correctly, however, when I select a record in the gridview to populate a DetailsView, I loose the original filter and so the returned page just contains an un-filtered grid view. When I put a breakpoint on page load I can see that the search text box is cleared and doesn't seem to keep it's value between this call and the last one. I have got ViewState turned on.
Any ideas how I can get around this? I guess it is something to do with the Server.Transfer , but I need to do this to get me onto the right page (since the text box doesn't have a postbackurl - (or is it the link button)).
Thanks
Will
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon Brooke |
last post by:
I'm investigating a bug a customer has reported in our database
abstraction layer, and it's making me very unhappy.
Brief summary:
I have a database abstraction layer which is intended to mediate
between webapps and arbitrary database backends using JDBC. I am very
unwilling indeed to write special-case code for particular
databases. Our code has worked satisfactorily with many databases,
including many instances MS SQLServer 2000...
|
by: multiformity |
last post by:
So I have been working on an opensource project for a while, and
decided to really try to make it look better after focusing on the
functionality most of this time. Up to now, I have simply used a
standard ASPX page with minor modifications to it. All of my pages
inherit from a "BasePage.cs" class, that handles common things like
getting the user's information out of the session, determines if a page
should or should not be password...
|
by: Thom Little |
last post by:
Visual Studio 2003 / .NET Framework 1.1 I could create multiple web
applications. In the root of a remote webspace I could have a single /bin
directory and a single web.config file.
I would then FTP (using a third-party FTP program) the .aspx files in any of
the applications to any directory in the webspace. I would also FTP all the
..dll files to the single /bin directory in the root.
Visual Studio 2005 / .NET Framework 2.0 does not...
|
by: William Buchanan |
last post by:
Hi folks
Why are master pages such a pain?
I have put a search text box and link button on my master page because I
want it on all pages on my site. After lots of juggling with the different
properties I managed to get it to work.
However, any page which has RequiredFieldValidators fail to submit the
search because it seems to check the required fields have been filled in
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |