473,703 Members | 3,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11217
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%******** ********@TK2MSF TNGP03.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.co m> wrote in message
news:es******** ******@TK2MSFTN GP02.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%******** ********@TK2MSF TNGP03.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.co m> wrote in message
news:es******* *******@TK2MSFT NGP02.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%******** ********@TK2MSF TNGP03.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***@emailadd ress.com> wrote in message
news:i4******** *************** *********@4ax.c om...
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.Visibl e to
false by default, and setting to true in button OnClick event.

When GridView.Visibl e 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
8356
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 strongly-typed collection, derived from CollectionBase, through the control's datasource property at runtime. From some googling it appears that, at least in the release candidate for NET2 this was a known bug; only binding to DataSources lets those...
8
8531
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 gridview's databind method is apparently called when the page is loaded as I have no code calling the databind method. How can I keep the gridview from databinding automatically and control it myself?
1
3527
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 javascript, nothing really having to do with ASP.NET... I'm attempting to put together an application that consists of several GridView controls each bound to some xml data. Each table exists in its own update panel. The two effects I'm going for are:
2
48402
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 was clicked?? I hope this makes sense? /Claus
4
26700
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
20897
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: myGridView.DataBind(); does not work! There is no clear method for the ODS. How do I get rid of it?
5
3002
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 list that corresponds with the number of pages, but I am unable to wire up the Selected Index Changed event. Auto PostBack is set to true and the page is posting back when the DDL is selected / chaged, but the event is never being called. Any...
11
6063
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 if that's what's causing the behavior or not. It seems like the Update button should at least do something. When the Edit button is clicked, the grid goes into Edit mode and the Cancel button takes the grid out of Edit mode. So, I don't get what...
3
5240
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 DataTable, I am using List of Objects. Here's one example: http://ryanolshan.com/technology/gridview-without-datasourcecontrol-datasource/
0
8662
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9243
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9002
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4420
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.