473,387 Members | 1,899 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,387 software developers and data experts.

Change SqlDataSource Parameter

I am trying to change the SQLDataSource parameter programatically but am
getting an error:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:CSpearAndAssociatesConnectionStr ing %>"
SelectCommand="GetQuestions" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="SurveyTestID" Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>

I tried:

SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue =
Request("ST")

But got the error:

Property access must assign to the property or use its value.

What am I missing?

Thanks

Tom
Sep 21 '08 #1
3 4247
On Sep 21, 10:47*pm, "tshad" <t...@dslextreme.comwrote:
I am trying to change the SQLDataSource parameter programatically but am
getting an error:

* * <asp:SqlDataSource ID="SqlDataSource1" runat="server"
* * * * ConnectionString="<%$
ConnectionStrings:CSpearAndAssociatesConnectionStr ing %>"
* * * * SelectCommand="GetQuestions" SelectCommandType="StoredProcedure">
* * * * <SelectParameters>
* * * * * * <asp:Parameter DefaultValue="1" Name="SurveyTestID" Type="Int32"
/>
* * * * </SelectParameters>
* * </asp:SqlDataSource>

I tried:

* * * SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue =
Request("ST")

But got the error:

* * Property access must assign to the property or use its value.

What am I missing?

Thanks

Tom
Tom,

is it VB or C#? :-) If you're using VB, use parenthesis instead of
brackets, and vice versa

Hope this helps
Sep 21 '08 #2
Alexey Smirnov wrote:
On Sep 21, 10:47 pm, "tshad" <t...@dslextreme.comwrote:
>I am trying to change the SQLDataSource parameter programatically
but am getting an error:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:CSpearAndAssociatesConnectionSt ring %>"
SelectCommand="GetQuestions" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="SurveyTestID" Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>

I tried:

SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue =
Request("ST")

But got the error:

Property access must assign to the property or use its value.

What am I missing?

Thanks

Tom

Tom,

is it VB or C#? :-) If you're using VB, use parenthesis instead of
brackets, and vice versa
That was it. I am doing projects in both VB.net and C# and sometimes miss
that.

BTW, why is it SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue
and not Value?

Thanks,

Tom
Hope this helps

Sep 21 '08 #3
On Sep 21, 11:44*pm, "tshad" <t...@dslextreme.comwrote:
Alexey Smirnov wrote:
On Sep 21, 10:47 pm, "tshad" <t...@dslextreme.comwrote:
I am trying to change the SQLDataSource parameter programatically
but am getting an error:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:CSpearAndAssociatesConnectionStr ing %>"
SelectCommand="GetQuestions" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="SurveyTestID" Type="Int32"
/>
</SelectParameters>
</asp:SqlDataSource>
I tried:
SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue =
Request("ST")
But got the error:
Property access must assign to the property or use its value.
What am I missing?
Thanks
Tom
Tom,
is it VB or C#? :-) If you're using VB, use parenthesis instead of
brackets, and vice versa

That was it. *I am doing projects in both VB.net and C# and sometimes miss
that.

BTW, why is it SqlDataSource1.SelectParameters["SurveyTestID"].DefaultValue
and not Value?

Thanks,

Tom
Hope this helps
Regarding Value. As MSDN says "A string that serves as a default value
for the Parameter when the value it is bound to cannot be resolved or
is uninitialized." In your code the value comes from SurveyTestID.

http://msdn.microsoft.com/en-us/libr...aultvalue.aspx
Sep 21 '08 #4

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

Similar topics

1
by: fuchs.markus | last post by:
Hello, on my page, I have a DetailsViewControl connected to a SqlDataSource. Now when I dynamically set the FilterExpression and FilterParameters - for example in a OnClick-EventHandler of a...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
2
by: stuart.d.jones | last post by:
Hi, I'm using a detailsview control with an SqlDataSource control. My Update query isn't working, and I've narrowed it down to the optimistic concurrency parameters - i.e. when I comment them...
3
by: Kees de Winter | last post by:
Hi, I am trying to set a parameter in the SELECT statement of a SqlDataSource, in the Page_Load event where the intended value for the parameter is calculated. But how can I set the parameter to...
0
by: André | last post by:
Hi, Still the same (unsolved problem), but other error now. I have a detailsview for inserting data, and a dropdownlist which selectedValue must be used to fill one of the field of the...
4
by: | last post by:
I'm building some user controls. I very much like how you can build custom properties to be bound to a user control, and how instances of that control will show those custom properties in the...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
0
by: danielhamd | last post by:
I am converting a website that uses an Access Database to SQL Server. On one particular SqlDataSource I am having a lot of trouble. Here is the original: <asp:SqlDataSource ID="SqlDataSource1"...
1
by: David C | last post by:
I have aspx web page with a GridView that displays data from a SqlDataSource view that combines 2 tables to show information. It has an Edit feature and the SqlDataSource has an UpdateCommand text...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.