473,395 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

More master page woes!

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
Apr 26 '06 #1
8 1400
NH
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

Apr 26 '06 #2
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 objectdatasource - I have added
it's code at the bottom:

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";

if (PreviousPage != null)
frm = PreviousPage.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }

hfSearch.Value = sQry;
}
<asp:ObjectDataSource ID="odsAdList" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="directory.data.DS_DirectoryTableAdapters .vwAdvertListTableAdapter"
FilterExpression="CompanyName like '%{0}%' or Descr like '%{0}%'">
<FilterParameters>
<asp:ControlParameter ControlID="hfSearch" Name="CompanyName"
PropertyName="Value"
Size="150" Type="String" />
</FilterParameters>
</asp:ObjectDataSource>

"NH" <NH@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.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

Apr 26 '06 #3
NH
try this...

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];

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.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
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 objectdatasource - I have added
it's code at the bottom:

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";

if (PreviousPage != null)
frm = PreviousPage.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }

hfSearch.Value = sQry;
}
<asp:ObjectDataSource ID="odsAdList" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="directory.data.DS_DirectoryTableAdapters .vwAdvertListTableAdapter"
FilterExpression="CompanyName like '%{0}%' or Descr like '%{0}%'">
<FilterParameters>
<asp:ControlParameter ControlID="hfSearch" Name="CompanyName"
PropertyName="Value"
Size="150" Type="String" />
</FilterParameters>
</asp:ObjectDataSource>

"NH" <NH@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.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


Apr 26 '06 #4
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**********************************@microsof t.com...
try this...

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];

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.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
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 objectdatasource - I have
added
it's code at the bottom:

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";

if (PreviousPage != null)
frm = PreviousPage.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }

hfSearch.Value = sQry;
}
<asp:ObjectDataSource ID="odsAdList" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="directory.data.DS_DirectoryTableAdapters .vwAdvertListTableAdapter"
FilterExpression="CompanyName like '%{0}%' or Descr like '%{0}%'">
<FilterParameters>
<asp:ControlParameter ControlID="hfSearch" Name="CompanyName"
PropertyName="Value"
Size="150" Type="String" />
</FilterParameters>
</asp:ObjectDataSource>

"NH" <NH@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.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
>>
>>
>>


Apr 26 '06 #5
NH
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**********************************@microsof t.com...
try this...

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];

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.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
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 objectdatasource - I have
added
it's code at the bottom:

protected void Page_Load(object sender, EventArgs e)
{
gvAdList.PageSize = (int)Session["GridPageSize"];
TextBox tb = null;
HtmlForm frm = null;
string sQry = "";

if (PreviousPage != null)
frm = PreviousPage.Form;
else if (Master != null)
frm = Form;

if (frm != null)
try
{
tb = (TextBox)frm.FindControl("tbMainSearch");
if (tb != null)
sQry = tb.Text;
}
catch { }

hfSearch.Value = sQry;
}
<asp:ObjectDataSource ID="odsAdList" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetData"
TypeName="directory.data.DS_DirectoryTableAdapters .vwAdvertListTableAdapter"
FilterExpression="CompanyName like '%{0}%' or Descr like '%{0}%'">
<FilterParameters>
<asp:ControlParameter ControlID="hfSearch" Name="CompanyName"
PropertyName="Value"
Size="150" Type="String" />
</FilterParameters>
</asp:ObjectDataSource>

"NH" <NH@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.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
>>
>>
>>


Apr 26 '06 #6
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**********************************@microsof t.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**********************************@microsof t.com...
> try this...
>
> protected void Page_Load(object sender, EventArgs e)
> {
> gvAdList.PageSize = (int)Session["GridPageSize"];
>
> 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.Form;
> else if (Master != null)
> frm = Form;
>
> if (frm != null)
> try
> {
> tb = (TextBox)frm.FindControl("tbMainSearch");
> 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 objectdatasource - I have
>> added
>> it's code at the bottom:
>>
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> gvAdList.PageSize = (int)Session["GridPageSize"];
>> TextBox tb = null;
>> HtmlForm frm = null;
>> string sQry = "";
>>
>> if (PreviousPage != null)
>> frm = PreviousPage.Form;
>> else if (Master != null)
>> frm = Form;
>>
>> if (frm != null)
>> try
>> {
>> tb = (TextBox)frm.FindControl("tbMainSearch");
>> if (tb != null)
>> sQry = tb.Text;
>> }
>> catch { }
>>
>> hfSearch.Value = sQry;
>> }
>>
>>
>> <asp:ObjectDataSource ID="odsAdList" runat="server"
>> OldValuesParameterFormatString="original_{0}"
>> SelectMethod="GetData"
>> TypeName="directory.data.DS_DirectoryTableAdapters .vwAdvertListTableAdapter"
>> FilterExpression="CompanyName like '%{0}%' or Descr like '%{0}%'">
>> <FilterParameters>
>> <asp:ControlParameter ControlID="hfSearch"
>> Name="CompanyName"
>> PropertyName="Value"
>> Size="150" Type="String" />
>> </FilterParameters>
>> </asp:ObjectDataSource>
>>
>> "NH" <NH@discussions.microsoft.com> wrote in message
>> news:69**********************************@microsof t.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
>> >>
>> >>
>> >>
>>
>>
>>


Apr 26 '06 #7
Sol
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.buchanan@naespam_freenet.co.uk> wrote in message
news:%2****************@TK2MSFTNGP04.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

Apr 26 '06 #8
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**************@TK2MSFTNGP03.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.buchanan@naespam_freenet.co.uk> wrote in
message news:%2****************@TK2MSFTNGP04.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


Apr 26 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
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...
14
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...
6
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.