Connecting Tech Pros Worldwide Forums | Help | Site Map

SqlDataSource control activating on button click

Hrvoje Vrbanc
Guest
 
Posts: n/a
#1: Dec 4 '07
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


Nanda Lella[MSFT]
Guest
 
Posts: n/a
#2: Dec 4 '07

re: SqlDataSource control activating on button click


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.

--------------------
Quote:
>From: "Hrvoje Vrbanc" <hrvojev@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: <OmEm$xoNIHA.4808@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
Quote:
>Delete calls to stored procedures and a GridView bound to SqlDataSource,
>
>- everything works fine, the date gets displayed when the page is loaded
and
Quote:
>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.

Hrvoje Vrbanc
Guest
 
Posts: n/a
#3: Dec 7 '07

re: SqlDataSource control activating on button click


Thank you very much, Nanda!
Hrvoje



"Nanda Lella[MSFT]" <NandaL@online.microsoft.comwrote in message
news:uuaeHjqNIHA.5204@TK2MSFTNGHUB02.phx.gbl...
Quote:
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.
>
--------------------
Quote:
>>From: "Hrvoje Vrbanc" <hrvojev@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: <OmEm$xoNIHA.4808@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
Quote:
>>Delete calls to stored procedures and a GridView bound to SqlDataSource,
>>
>>- everything works fine, the date gets displayed when the page is loaded
and
Quote:
>>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.
>



Closed Thread