473,385 Members | 1,873 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,385 software developers and data experts.

Getting DataRepeater control to work without binding EVERY time

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
Jun 27 '08 #1
7 1685
Joe
Maybe I'm making this too simple. You said on the inital load of the
search page there would be no results. Then once they search the
results should show.

Remove all the code from the page_load you have shown. Put the
DoSearch() function in the button click event. Make sure you finish
by binding the data to your repeater.

-joe
Jun 27 '08 #2
No, the problem is that my problem SOUNDS too simple. I did exactly
what you suggested before I posted this problem. If I remove any code
from the Page_Load which results in DataBinding, the search does not
work whenever I press the search button. I mean, the search works, but
the ItemCommand event does not fire on the repeater. Because of this,
the ID of the record does not get populated, and I cannot view the
details, when I press the button present in the DataRepeater.

Thanks for your time. And sorry for not being so clear the first time.

Regards,
--Jaffar
Jun 27 '08 #3
On Jun 3, 2:00 pm, jaffarkazi <jaffar.k...@gmail.comwrote:
No, the problem is that my problem SOUNDS too simple. I did exactly
what you suggested before I posted this problem. If I remove any code
from the Page_Load which results in DataBinding, the search does not
work whenever I press the search button. I mean, the search works, but
the ItemCommand event does not fire on the repeater. Because of this,
the ID of the record does not get populated, and I cannot view the
details, when I press the button present in the DataRepeater.

Thanks for your time. And sorry for not being so clear the first time.

Regards,
--Jaffar
Hi

Try Remove the Page's DataBind() method invocation at the top of the
page...

First of all there should not be any code in the page_load event of
your scenario , thing are pretty simple in your case...
1. Get the search option from somewhere (where from the search query
come from by the way?)
2. Execute the search ...
3. Get the result
4. bind it to result grid and save the result in session or somewhere
else to use it for later use.

In your case
if (!IsPostBack)
{
LoadDefinedData();

DoSearch(); //this code is useless
}
DoSearch(); //since this will be execute any way...

please investigate your search binding scenario...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #4
sounds like you have viewstate disabled on the repeater
"jaffarkazi" <ja*********@gmail.comwrote in message
news:1b**********************************@p39g2000 prm.googlegroups.com...
No, the problem is that my problem SOUNDS too simple. I did exactly
what you suggested before I posted this problem. If I remove any code
from the Page_Load which results in DataBinding, the search does not
work whenever I press the search button. I mean, the search works, but
the ItemCommand event does not fire on the repeater. Because of this,
the ID of the record does not get populated, and I cannot view the
details, when I press the button present in the DataRepeater.

Thanks for your time. And sorry for not being so clear the first time.

Regards,
--Jaffar

Jun 27 '08 #5
On Jun 3, 4:10 pm, "gerry" <g...@newsgroup.nospamwrote:
sounds like you have viewstate disabled on the repeater

"jaffarkazi" <jaffar.k...@gmail.comwrote in message

news:1b**********************************@p39g2000 prm.googlegroups.com...
No, the problem is that my problem SOUNDS too simple. I did exactly
what you suggested before I posted this problem. If I remove any code
from the Page_Load which results in DataBinding, the search does not
work whenever I press the search button. I mean, the search works, but
the ItemCommand event does not fire on the repeater. Because of this,
the ID of the record does not get populated, and I cannot view the
details, when I press the button present in the DataRepeater.
Thanks for your time. And sorry for not being so clear the first time.
Regards,
--Jaffar
Tried enabling that too! :) No solution.
Jun 27 '08 #6
is it enabled on all containers as well ? ie usercontrol , page ... have
you posted an actual example of this problem somewhere ?
"jaffarkazi" <ja*********@gmail.comwrote in message
news:63**********************************@56g2000h sm.googlegroups.com...
On Jun 3, 4:10 pm, "gerry" <g...@newsgroup.nospamwrote:
>sounds like you have viewstate disabled on the repeater

"jaffarkazi" <jaffar.k...@gmail.comwrote in message

news:1b**********************************@p39g200 0prm.googlegroups.com...
No, the problem is that my problem SOUNDS too simple. I did exactly
what you suggested before I posted this problem. If I remove any code
from the Page_Load which results in DataBinding, the search does not
work whenever I press the search button. I mean, the search works, but
the ItemCommand event does not fire on the repeater. Because of this,
the ID of the record does not get populated, and I cannot view the
details, when I press the button present in the DataRepeater.
Thanks for your time. And sorry for not being so clear the first time.
Regards,
--Jaffar

Tried enabling that too! :) No solution.

Jun 27 '08 #7
No, not posted it anywhere.
I've found a workaround/temporary solution/whatever you call it.

Earlier I was using buttons to go to the details page from search. Now
I'm using URLs, with the ID being passed as part of the URL.

Now, the code which was actually wrong, i.e., SearchData in Page_Load
has been correctly removed, and it works properly.

Thanks everyone for your time.

Regards,
--jaffar
Jun 27 '08 #8

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
2
by: RSB | last post by:
Hi Every one, I am currently using Visual Studio .Net and trying to open a project from SourceSafe and once i open the project for the first time i get the following error/warning... "The...
2
by: muhamad | last post by:
Hi, How can I use the DataRepeater in CSharp , this control exists in VB6 ,i never used it . I want to insert into the DataRepeater TextBoxs that will show all the time data from the database ....
3
by: | last post by:
Hi, NG! Is there any updated version (.Net) of the Datarepeater control or do I have to use the old (VS6.0) version? Thanks. pax
11
by: John J. Hughes II | last post by:
I have a DataGridView displaying data from a DataSet. To the right of that I have a custom user control which displays one of the data set fields. The custom user control is bound to the data set...
1
by: David Veeneman | last post by:
How do I get the data bindings for a control that is bound at design time? I'm binding a DataGridView control to a data source at design time, using a BindingSource control. I set the grid's...
1
by: TC | last post by:
I'm using Visual Studio 2005 with SourceGear Vault. I'm having trouble with the integrated source code control features. I think the problem is entirely with Visual Studio, not Vault. First, let...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
0
by: morathm | last post by:
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.