By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

GridView binding - how to stop initial binding

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.