J
jaffarkazi
Hi all,
I'm developing a site. One of the features is a search page, for which
I'm using a data repeater control.
For the rest of the pages it is fine, but, obviously, on the search
page, for the first time, there will be no search results. Only when
the user specifies his search parameters will the search show up.
The Page_Load event for the search control looks as follows:
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
if (!IsPostBack)
{
LoadDefinedData();
DoSearch();
}
DoSearch();
}
and other methods are:
protected void btnSearch_Click(object sender, EventArgs e)
{
DoSearch();
}
private void DoSearch()
{
...prepare params
if (csi.Search(params))
{
Repeater.DataSource = csi.DefaultView;
Repeater.DataBind();
}
}
So I'm having to hit the database TWICE for each request. If I remove
the 2nd DoSearch from the Page_Load, then no data shows up, and I
actually want to remove both the DoSearch()es from the Page_load, and
just rely on the Search_Click DoSearch.
How can I achieve this? I've gone MAD trying to get this stupid
straight forward thing to work, and I need to put it into production
as soon as possible.
Thanks in advance, and all help appreciated.
Regards,
--Jaffar
I'm developing a site. One of the features is a search page, for which
I'm using a data repeater control.
For the rest of the pages it is fine, but, obviously, on the search
page, for the first time, there will be no search results. Only when
the user specifies his search parameters will the search show up.
The Page_Load event for the search control looks as follows:
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
if (!IsPostBack)
{
LoadDefinedData();
DoSearch();
}
DoSearch();
}
and other methods are:
protected void btnSearch_Click(object sender, EventArgs e)
{
DoSearch();
}
private void DoSearch()
{
...prepare params
if (csi.Search(params))
{
Repeater.DataSource = csi.DefaultView;
Repeater.DataBind();
}
}
So I'm having to hit the database TWICE for each request. If I remove
the 2nd DoSearch from the Page_Load, then no data shows up, and I
actually want to remove both the DoSearch()es from the Page_load, and
just rely on the Search_Click DoSearch.
How can I achieve this? I've gone MAD trying to get this stupid
straight forward thing to work, and I need to put it into production
as soon as possible.
Thanks in advance, and all help appreciated.
Regards,
--Jaffar