Change SqlDataSource Parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    Change SqlDataSource Parameter

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

    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ConnectionStrin g="<%$
    ConnectionStrin gs:CSpearAndAss ociatesConnecti onString %>"
    SelectCommand=" GetQuestions" SelectCommandTy pe="StoredProce dure">
    <SelectParamete rs>
    <asp:Paramete r DefaultValue="1 " Name="SurveyTes tID" Type="Int32"
    />
    </SelectParameter s>
    </asp:SqlDataSour ce>

    I tried:

    SqlDataSource1. SelectParameter s["SurveyTest ID"].DefaultValue =
    Request("ST")

    But got the error:

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

    What am I missing?

    Thanks

    Tom


  • Alexey Smirnov

    #2
    Re: Change SqlDataSource Parameter

    On Sep 21, 10:47 pm, "tshad" <t...@dslextrem e.comwrote:
    I am trying to change the SQLDataSource parameter programatically but am
    getting an error:
    >
        <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
            ConnectionStrin g="<%$
    ConnectionStrin gs:CSpearAndAss ociatesConnecti onString %>"
            SelectCommand=" GetQuestions" SelectCommandTy pe="StoredProce dure">
            <SelectParamete rs>
                <asp:Paramete r DefaultValue="1 " Name="SurveyTes tID" Type="Int32"
    />
            </SelectParameter s>
        </asp:SqlDataSour ce>
    >
    I tried:
    >
          SqlDataSource1. SelectParameter s["SurveyTest ID"].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

    Comment

    • tshad

      #3
      Re: Change SqlDataSource Parameter

      Alexey Smirnov wrote:
      On Sep 21, 10:47 pm, "tshad" <t...@dslextrem e.comwrote:
      >I am trying to change the SQLDataSource parameter programatically
      >but am getting an error:
      >>
      ><asp:SqlDataSo urce ID="SqlDataSour ce1" runat="server"
      >ConnectionStri ng="<%$
      >ConnectionStri ngs:CSpearAndAs sociatesConnect ionString %>"
      >SelectCommand= "GetQuestio ns" SelectCommandTy pe="StoredProce dure">
      ><SelectParamet ers>
      ><asp:Paramet er DefaultValue="1 " Name="SurveyTes tID" Type="Int32"
      >/>
      ></SelectParameter s>
      ></asp:SqlDataSour ce>
      >>
      >I tried:
      >>
      >SqlDataSource1 .SelectParamete rs["SurveyTest ID"].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. SelectParameter s["SurveyTest ID"].DefaultValue
      and not Value?

      Thanks,

      Tom
      Hope this helps

      Comment

      • Alexey Smirnov

        #4
        Re: Change SqlDataSource Parameter

        On Sep 21, 11:44 pm, "tshad" <t...@dslextrem e.comwrote:
        Alexey Smirnov wrote:
        On Sep 21, 10:47 pm, "tshad" <t...@dslextrem e.comwrote:
        I am trying to change the SQLDataSource parameter programatically
        but am getting an error:
        >
        <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
        ConnectionStrin g="<%$
        ConnectionStrin gs:CSpearAndAss ociatesConnecti onString %>"
        SelectCommand=" GetQuestions" SelectCommandTy pe="StoredProce dure">
        <SelectParamete rs>
        <asp:Paramete r DefaultValue="1 " Name="SurveyTes tID" Type="Int32"
        />
        </SelectParameter s>
        </asp:SqlDataSour ce>
        >
        I tried:
        >
        SqlDataSource1. SelectParameter s["SurveyTest ID"].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. SelectParameter s["SurveyTest ID"].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.

        Gain technical skills through documentation and training, earn certifications and connect with the community

        Comment

        Working...