It seems to me that you have confused a DataSource control with a
DataAdapter (or TableAdapter). You need to keep in mind that
DataSource controls only expose a representation of a data store to a
bindable UI control. They exist for that purpose only, not to run
queries on a back-end. The DataSource controls call their various
commands (selectcommand, updatecommand, etc.) only when the DataBind
method of the Bound control is invoked.

Both your original sample and the standalone sample make one thing
obvious - The SqlDataSource_Selecting event will never be raised
because you are never actually binding any control on the page to the
Datasource. In any case, you should not need to use the Selecting
event to do the binding. Binding is a declarative measure in .NET 2.0.

On Nov 8, 3:17 am, Justin <[EMAIL PROTECTED]> wrote:
> I changed the labels so they're not hard coded anymore, its set in
> Page_Load, not sure what you mean about the code though.
>
> Anyways, I figured out that if I add a Gridview and bind it to the
> datasource, then it works fine.  I'm thinking that the sqldatasource
> is not querying the database, and thus, not firing the
> SqlDataSource1_Selecting function.  Is there a way to manually get the
> datasource to query?
>
> On Nov 7, 1:23 pm, KeidrickP <[EMAIL PROTECTED]> wrote:
>
>
>
> > ok you have several things wrong here, I`m not sure how this was
> > working properly at all.
> > On label first name you have text hardcoded
> >  <asp:Label ID="LabelFirstName" runat="server" Text="Label">First
> > Name:</asp:Label>
> > Try putting what you want to say here in the page load event of this page.
> > Next I would recommend using the code behind pages rather performing
> > your functions inline, it makes it easier to read, and catch your
> > errors.
> > See if you can figure this part out, and you can go from there
>
> > On Fri, Nov 7, 2008 at 3:11 PM, Justin <[EMAIL PROTECTED]> wrote:
>
> > > Here's a stand alone page that exhibits my problem....
>
> > > <%@ Page Language="VB" %>
>
> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> > >www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> > > <script runat="server">
>
> > >    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> > > System.EventArgs)
> > >        SqlDataSource1.SelectParameters.Add("UserName",
> > > System.Web.HttpContext.Current.User.Identity.Name.ToString)
> > >    End Sub
>
> > >    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object,
> > > ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)
> > >        Username.Text = e.Command.Parameters("@UserName").Value _
> > >                & "'s Profile"
> > >    End Sub
>
> > > </script>
>
> > > <html xmlns="http://www.w3.org/1999/xhtml";>
> > > <head runat="server">
> > >    <title></title>
> > > </head>
> > > <body>
> > >    <form id="form1" runat="server">
> > >    <div>
> > >        <asp:Label ID="Username" runat="server" Text="Label"></
> > > asp:Label>
> > >    </div>
> > >    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> > >        ConnectionString="<%$
> > > ConnectionStrings:UserInfoConnectionString %>"
> > >        onselecting="SqlDataSource1_Selecting"
> > >        SelectCommand="SELECT * FROM [UserInfo] WHERE ([UserName] =
> > > @UserName)">
> > >        <SelectParameters>
> > >            <asp:Parameter Name="UserName" Type="String" />
> > >        </SelectParameters>
> > >    </asp:SqlDataSource>
> > >    </form>
> > > </body>
> > > </html>- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to