Also...I used QueryStringParameter and it worked fine...but i was just
curious as to how this could be done using C#.  Thanks.

On Nov 12, 2:26 pm, BigJ <[EMAIL PROTECTED]> wrote:
> Thanks,
>
> So being that I leave
>
>       <SelectParameters>
>             <asp:Parameter Name="UserId" Type="String" Size="100"
> DefaultValue="untitled"/>
>        </SelectParameters>
>
> in the code, and in addition use OnSelecting as follows:
>
>         <asp:SqlDataSource
>         id="srcProfileView"
>         ConnectionString="<%$ ConnectionStrings:webBlog %>"
>         SelectCommandType="StoredProcedure"
>         SelectCommand="profileInfo"
>         Runat="server"
>         OnSelecting="get_UserId">
>
> what is the correct syntax in get_UserId to set the value of the
> select parameter field "UserId"?  The following is what I have, and it
> is erroring out:
>
>     void get_UserId() {
>         String UserVal = Page.Request.Params.Get("UserId");
>         srcProfileView.SelectParameters.Add(new Parameter
> (@UserId,TypeCode.String,UserVal));
>     }
>
> Thanks
>
> Jon
>
> On Nov 10, 9:38 pm, Cerebrus <[EMAIL PROTECTED]> wrote:
>
> > 1. It appears that your parameter value is equivalent to something
> > passed in the QueryString or through the Form collection. In these
> > cases, it would be more appropriate for you to simply use a
> > QueryStringParameter or FormParameter. This would obviate the need for
> > setting your Parameter on Page load.
>
> > 2. Since you are interested only in the SelectCommand, the
> > SqlDataSource_Selecting event is the place to set the value of the
> > Parameter. Page_Load would not be the correct place, IMHO.
>
> > 3. You should not be adding a new Parameter, but should instead access
> > the declared Parameter and set it's value, or else it invalidates the
> > purpose of using the Declarative model.
>
> > On Nov 11, 8:35 am, BigJ <[EMAIL PROTECTED]> wrote:
>
> > > In my sqlDataConnection I have :
>
> > > //=============================================================
> > >         <asp:SqlDataSource
> > >         id="srcProfileView"
> > >         ConnectionString="<%$ ConnectionStrings:webBlog %>"
> > >         SelectCommandType="StoredProcedure"
> > >         SelectCommand="profileInfo"
> > >         Runat="server">
>
> > >        <SelectParameters>
> > >             <asp:Parameter Name="UserId" Type="String" Size="100"
> > > DefaultValue="Untitled"/>
> > >        </SelectParameters>
> > >        </asp:SqlDataSource>
> > > //=============================================================
>
> > > However, I want to make the value of "UserId" dynamic with what's
> > > being passed in from the URL, I took out the <selectparameter> tag and
> > > in my Page_load I did the following:
>
> > > //=============================================================
> > >     void Page_Load()
> > >     {
> > >         String UserId = Page.Request.Params.Get("UserId");
> > >         srcProfileView.SelectParameters.Add(new
> > > Parameter(@UserId,TypeCode.String,UserId));
> > >     }
> > > //=============================================================
>
> > > From what I understand this should Add a new parameter to the
> > > sqlDataConnection control with the name "UserId" and whatever the
> > > value of UserId is.  However I'm getting the error that my stored
> > > procedure expects a value for @UserId.  Any insight?
>
> > > Thanks

Reply via email to