473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Setting asp:parameter at runtime - possible?

Hi guys

I have the following AccessDataSource control on my page..

<asp:AccessDataSource ID="adsAllStories" runat="server"
DataFile="~/App_Data/Stories.mdb"
SelectCommand="SELECT StoryID, StoryTitle FROM Stories WHERE
StoryTitle LIKE '?%' ORDER BY StoryID DESC">
<SelectParameters>
<asp:Parameter Type="char" DefaultValue="A" Name="AllParam" />
</SelectParameters>
</asp:AccessDataSource>

I also have a code generate A-Z link list, which when clicked reload the
page with the querystring ?id= <whichever letter I click>

I'm trying to change the value of the AllParam property on the datasource
when we read the querystring, but i can only find DefaultValue as a property,
and when I watch it, it says that "DefaultValue does not exist in the current
context".

The code I'm using in Page_PreRender is...

adsAllStories.SelectParameters["AllParam"].DefaultValue = showChar; // a char

I'm not using a querystringparameter because I'm performing other functions
on showChar before I pass it to the SelectParameters.

But.. how can I pass it to the accessDataSource?!?!

Thanks,

Dan

Feb 26 '07 #1
5 8304
I also have a code generate A-Z link list, which when clicked reload the
page with the querystring ?id= <whichever letter I click>
But.. how can I pass it to the accessDataSource?!?!
Why don't you add a "QueryStringParamter"?

<SelectParameters>
<asp:SelectParameter name='SQL_Query_Parameter_Name'
QueryStringField='Query_String_Parameter_Name' />
</SelectParameters>
For your case:
<SelectParameters>
<asp:SelectParameter name='AllParam' QueryStringField='id' />
</SelectParameters>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Feb 26 '07 #2
Gaurav,

I want to do something to the querystring before it's passed into the
accessdatasource. This is why I haven't used to <querystringoption.

"MasterGaurav (www.edujini-labs.com)" wrote:
I also have a code generate A-Z link list, which when clicked reload the
page with the querystring ?id= <whichever letter I click>
But.. how can I pass it to the accessDataSource?!?!

Why don't you add a "QueryStringParamter"?

<SelectParameters>
<asp:SelectParameter name='SQL_Query_Parameter_Name'
QueryStringField='Query_String_Parameter_Name' />
</SelectParameters>
For your case:
<SelectParameters>
<asp:SelectParameter name='AllParam' QueryStringField='id' />
</SelectParameters>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Feb 26 '07 #3
Howdy,

Handle AccessDataSource.Selecting event.
BTW I'm quessing there is an error in the query:
LIKE '?%' ORDER BY StoryID DESC
should be
LIKE ? & '%' ORDER BY StoryID DESC

Hope this helps
--
Milosz
"musosdev" wrote:
Gaurav,

I want to do something to the querystring before it's passed into the
accessdatasource. This is why I haven't used to <querystringoption.

"MasterGaurav (www.edujini-labs.com)" wrote:
I also have a code generate A-Z link list, which when clicked reload the
page with the querystring ?id= <whichever letter I click>
>
But.. how can I pass it to the accessDataSource?!?!
Why don't you add a "QueryStringParamter"?

<SelectParameters>
<asp:SelectParameter name='SQL_Query_Parameter_Name'
QueryStringField='Query_String_Parameter_Name' />
</SelectParameters>
For your case:
<SelectParameters>
<asp:SelectParameter name='AllParam' QueryStringField='id' />
</SelectParameters>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------

Feb 26 '07 #4
Hi Dan,

The AccessDataSource.SelectParameters are used to define parameters. To
change the parameter value at run-time, you need to do this in the
Selecting event and use the Command.Parameters collection:

protected void AccessDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["AllParam"].Value = ...;
}

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Feb 27 '07 #5
Thank you both!

"Walter Wang [MSFT]" wrote:
Hi Dan,

The AccessDataSource.SelectParameters are used to define parameters. To
change the parameter value at run-time, you need to do this in the
Selecting event and use the Command.Parameters collection:

protected void AccessDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["AllParam"].Value = ...;
}

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Feb 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: matt | last post by:
Hi There we have a new asp.net site that is getting a lot of hits. I have set this up on its own server with its own database server. We have a search system built into the site which is timing...
2
by: J Krugman | last post by:
I have a form with a couple of submit buttons, plus a "pseudolink" that is also supposed to submit the form; the submitted form data feeds to a CGI script. The two submit buttons have the name...
3
by: Torsten Bronger | last post by:
Hallöchen! I have to generate excerpts in different human languages in a program. In general, the language is not the locale's language, but set at runtime. Nevertheless, GNU's gettext should...
8
by: Rick Strahl [MVP] | last post by:
Hi all, I'm building an app that uses the ASP.Net runtime... One problem I've run into is that pages running inside of the runtime are not finding DLLs in the GAC. In fact, if I look at the...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
1
by: abcd | last post by:
How do I determine that ASP.NET runtime 1.1 is installed on the machine?
3
by: Newbie | last post by:
Hi, For my recent web project, I need to built a site which has 3 language. The content pages are identical, so it only the language that differ. What I planned is: I'll build a masterpage for...
12
by: karanj | last post by:
Hi all, I'm facing an issue with Access that I haven't been able to find a solution for, despite hours of googling, so I hope someone here can help! I've got a report - rptClientsByCountry -...
1
by: sergiockgoh82 | last post by:
I faced the problem of debugging in my Web application development. The problem as below: ASP.net runtime error: ' insufficient state return the real object ' while i try to debug in MS...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.