473,320 Members | 2,124 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,320 software developers and data experts.

GridView binding - how to stop initial binding

Hello,
I have a simple search screen, with two drop-downs and a text box. There's
also a GridView control that is using a SqlDataSource control to show the
matching results. The SqlDataSource uses the control values in its query as
parameters. Two questions:

1. When the Find button is clicked, how do I tell the GridView to load the
data?
2. How do I stop the GridView from data binding when the page first loads? I
don't want to pre-populate the grid, it should only show the data after the
Find button is clicked

Thanks
Amit
Apr 29 '06 #1
5 11185
Call myGrid.DataBind (); in the Find button OnClick event handler. This will
solve both problems.

Eliyahu

"Amit" <re***********@hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP03.phx.gbl...
Hello,
I have a simple search screen, with two drop-downs and a text box. There's
also a GridView control that is using a SqlDataSource control to show the
matching results. The SqlDataSource uses the control values in its query
as parameters. Two questions:

1. When the Find button is clicked, how do I tell the GridView to load the
data?
2. How do I stop the GridView from data binding when the page first loads?
I don't want to pre-populate the grid, it should only show the data after
the Find button is clicked

Thanks
Amit

Apr 30 '06 #2
I tried that but it didn't load the grid. I kept the SQL Profiler running
and it didn't even send a database query.
-Amit

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:es**************@TK2MSFTNGP02.phx.gbl...
Call myGrid.DataBind (); in the Find button OnClick event handler. This
will solve both problems.

Eliyahu

"Amit" <re***********@hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP03.phx.gbl...
Hello,
I have a simple search screen, with two drop-downs and a text box.
There's also a GridView control that is using a SqlDataSource control to
show the matching results. The SqlDataSource uses the control values in
its query as parameters. Two questions:

1. When the Find button is clicked, how do I tell the GridView to load
the data?
2. How do I stop the GridView from data binding when the page first
loads? I don't want to pre-populate the grid, it should only show the
data after the Find button is clicked

Thanks
Amit


Apr 30 '06 #3
On Sun, 30 Apr 2006 14:29:59 -0400, "Amit" <re***********@hotmail.com> wrote:
I tried that but it didn't load the grid. I kept the SQL Profiler running
and it didn't even send a database query.
-Amit

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:es**************@TK2MSFTNGP02.phx.gbl...
Call myGrid.DataBind (); in the Find button OnClick event handler. This
will solve both problems.

Eliyahu

"Amit" <re***********@hotmail.com> wrote in message
news:u%****************@TK2MSFTNGP03.phx.gbl...
Hello,
I have a simple search screen, with two drop-downs and a text box.
There's also a GridView control that is using a SqlDataSource control to
show the matching results. The SqlDataSource uses the control values in
its query as parameters. Two questions:

1. When the Find button is clicked, how do I tell the GridView to load
the data?
2. How do I stop the GridView from data binding when the page first
loads? I don't want to pre-populate the grid, it should only show the
data after the Find button is clicked

Thanks
Amit



Amit,

If you want to populate the grid using the criteria from the drop downs you must
do it the way Eliyahu told you, but now you will have to call your
DatatAdapter's Fill method in the click event.

To prevent the grid from filling the first time you load the page, move the
DataAdapter's Fill method to the click event. That will keep it from loading on
the page load.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Apr 30 '06 #4
Otis,
Thanks for your reply. I was using the SqlDataSource object bound to a
stored procedure to do the binding. But now it looks like I have to do the
binding myself, without using the SqlDataSource object.
Thanks
Amit
"Otis Mukinfus" <ph***@emailaddress.com> wrote in message
news:i4********************************@4ax.com...
Amit,

If you want to populate the grid using the criteria from the drop downs
you must
do it the way Eliyahu told you, but now you will have to call your
DatatAdapter's Fill method in the click event.

To prevent the grid from filling the first time you load the page, move
the
DataAdapter's Fill method to the click event. That will keep it from
loading on
the page load.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com

May 1 '06 #5
You can prevent initial GridView binding by setting GridView.Visible to
false by default, and setting to true in button OnClick event.

When GridView.Visible is set to false the DataSource select command
will not be executed.

Amit wrote:
Hello,
I have a simple search screen, with two drop-downs and a text box. There's
also a GridView control that is using a SqlDataSource control to show the
matching results. The SqlDataSource uses the control values in its query as
parameters. Two questions:

1. When the Find button is clicked, how do I tell the GridView to load the
data?
2. How do I stop the GridView from data binding when the page first loads? I
don't want to pre-populate the grid, it should only show the data after the
Find button is clicked

Thanks
Amit


May 10 '06 #6

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

Similar topics

5
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a...
8
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The...
1
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all...
2
by: cartmann | last post by:
Hi, I have a gridview with a template column. In the template column i have two commandbuttons. When clicking the buttons I enter the cmd_click event - but how do I read in which row the button...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
4
by: GaryDean | last post by:
I have an objectdatasource reading a dataset and I have a gridview using that objectdatasource (at design time). It binds fine but I need to clear it. myGridView.DataSource = null:...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.