RE: Modify SqlDataSource parameters before select

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Steven,
thanks for your reply. In fact, what you describe is exactly what I have
done so far. But how to continue from there, how do I access and modify the
SqlDataSource's parameter values? I have not found any documentation / sample
about that.

Martin Bischoff


"Steven Cheng[MSFT]" wrote:

> Hi Martin,
>
> Welcome to ASPNET newsgroup.
> As for the modifying SqlDataSource's parameters before the select command
> actually get executed, we can utilize the
> SqlDataSource control's "Selecting" event, this event get fired before the
> actual execute command being executed. the event will have a
> SqlDataSourceSelectingEventArgs paramter passed in which can help us
> access the paramters used to perform the select comand:
>
> protected void SqlDataSource1_Selecting(object sender,
> SqlDataSourceSelectingEventArgs e)
> {
>
> }
>
> In fact, in asp.net 2.0 , all the datasource controls support some buildin
> pre/post processsing events such as
> "selecting/selected", "updating/updated"..... which get fired before/after
> a certain command executing.
>
> Hope helps. Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
> --------------------
> | Thread-Topic: Modify SqlDataSource parameters before select
> | thread-index: AcXVY3bXKFhY+ZLJTQeWe1aVqsr9nA==
> | X-WBNR-Posting-Host: 194.209.202.1
> | From: =?Utf-8?B?TWFydGluIEJpc2Nob2Zm?= <nitramb4@xxxxxxxxxxxxxxxx>
> | Subject: Modify SqlDataSource parameters before select
> | Date: Thu, 20 Oct 2005 03:46:02 -0700
> | Lines: 24
> | Message-ID: <A77A5B33-2C75-41A5-87D0-9892C0D2B5C8@xxxxxxxxxxxxx>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> | charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.aspnet
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA01.phx.gbl
> microsoft.public.dotnet.framework.aspnet:132687
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
> |
> | Hi,
> | is it possible to modify the values of a SqlDataSource's select
> parameters
> | in the code behind before the select command is executed?
> |
> | Example:
> |
> | I have an SqlDataSource with a ControlParameter
> |
> | <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> | ConnectionString="<%$ ConnectionStrings:XYZ %>"
> | SelectCommand="myStoredProcedure"
> | SelectCommandType="storedProcedure">
> | <SelectParameters>
> | <asp:ControlParameter ControlID="txtTitle" Name="Title"
> | PropertyName="Text" Type="String" DefaultValue="%" />
> | </SelectParameters>
> | </asp:SqlDataSource>
> |
> | What I'd like to do is to modify the value of the Title parameter before
> the
> | select command is executed. E.g. if the user enters "abc*" in txtTitle,
> I'd
> | like to change the parameter's value to "abc%".
> |
> | Thanks for any help,
> | Martin
> |
>
>
.



Relevant Pages