469,641 Members | 1,283 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

SqlDataSource control activating on button click

Hello all!

As I have only recently started to use native ASP.NET 2.0 data access
controls (and found them to be very powerful), I have one question that I
was unable to find the answer to:

- I have an ASPX page with a SqlDataSource control with Select, Update and
Delete calls to stored procedures and a GridView bound to SqlDataSource,

- everything works fine, the date gets displayed when the page is loaded and
Delete ad Update also work OK.

Now, I want the page not to display any data until a button is clicked, or
better said until a button is clicked and a value from a TextBox is passed
as a Select statement parameter to the SqlDataSource.

How to prevent the GridView from filling onLoad and how to refresh it on
Button click?

Thank you in advance,
Hrvoje
Dec 4 '07 #1
2 4576
You can bind the datasource of the gridview on button click.
I mean, in the button click routine, Add code similar to
Gridview1.DataSource = SqlDataSource1;
GridView1.DataBind();
And remove the DataSource part from the GridView definition/declaration in
the aspx page.

Hope this helps.

--------------------
>From: "Hrvoje Vrbanc" <hr*****@recro.hr>
Subject: SqlDataSource control activating on button click
Date: Tue, 4 Dec 2007 16:44:01 +0100
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Message-ID: <Om**************@TK2MSFTNGP05.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dalmatinac.recro.hr 195.137.173.99
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP05.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:52358
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello all!

As I have only recently started to use native ASP.NET 2.0 data access
controls (and found them to be very powerful), I have one question that I
was unable to find the answer to:

- I have an ASPX page with a SqlDataSource control with Select, Update
and
>Delete calls to stored procedures and a GridView bound to SqlDataSource,

- everything works fine, the date gets displayed when the page is loaded
and
>Delete ad Update also work OK.

Now, I want the page not to display any data until a button is clicked, or
better said until a button is clicked and a value from a TextBox is passed
as a Select statement parameter to the SqlDataSource.

How to prevent the GridView from filling onLoad and how to refresh it on
Button click?

Thank you in advance,
Hrvoje
--

Thank You,
Nanda Lella,

This Posting is provided "AS IS" with no warranties, and confers no rights.

Dec 4 '07 #2
Thank you very much, Nanda!
Hrvoje

"Nanda Lella[MSFT]" <Na****@online.microsoft.comwrote in message
news:uu**************@TK2MSFTNGHUB02.phx.gbl...
You can bind the datasource of the gridview on button click.
I mean, in the button click routine, Add code similar to
Gridview1.DataSource = SqlDataSource1;
GridView1.DataBind();
And remove the DataSource part from the GridView definition/declaration in
the aspx page.

Hope this helps.

--------------------
>>From: "Hrvoje Vrbanc" <hr*****@recro.hr>
Subject: SqlDataSource control activating on button click
Date: Tue, 4 Dec 2007 16:44:01 +0100
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
Message-ID: <Om**************@TK2MSFTNGP05.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dalmatinac.recro.hr 195.137.173.99
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP05.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:52358
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello all!

As I have only recently started to use native ASP.NET 2.0 data access
controls (and found them to be very powerful), I have one question that I
was unable to find the answer to:

- I have an ASPX page with a SqlDataSource control with Select, Update
and
>>Delete calls to stored procedures and a GridView bound to SqlDataSource,

- everything works fine, the date gets displayed when the page is loaded
and
>>Delete ad Update also work OK.

Now, I want the page not to display any data until a button is clicked, or
better said until a button is clicked and a value from a TextBox is passed
as a Select statement parameter to the SqlDataSource.

How to prevent the GridView from filling onLoad and how to refresh it on
Button click?

Thank you in advance,
Hrvoje

--

Thank You,
Nanda Lella,

This Posting is provided "AS IS" with no warranties, and confers no
rights.

Dec 7 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mike T | last post: by
8 posts views Thread by cider123 | last post: by
reply views Thread by kurt.craver | last post: by
reply views Thread by Sobin Thomas | last post: by
1 post views Thread by Sobin Thomas | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.