Ho do I access sqldatasource in Code Behind?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markpringle
    New Member
    • Jul 2008
    • 5

    Ho do I access sqldatasource in Code Behind?

    This is my sqldatasource this is on the page:

    Code:
    <asp:sqldatasource runat="server"  ID="DS_CheckUserName"  
        ConnectionString="<%$ ConnectionStrings:SQL2005_355184_ConnectionString %>" 
        SelectCommand="SELECT [UserName] FROM [TBL_Poets] WHERE ([UserName] = @UserName)">
        <SelectParameters>
            <asp:FormParameter FormField="UserName" Name="UserName" Type="String" />
        </SelectParameters>
    How do I access the selected UserName in in the Code Behind that might look like this...

    Code:
    if (UserName.Text != [B]DS_CheckUserName.UserName[/B])
    ...where DS_CheckUserNam e.UserName is the UserName selected in the code above?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    I'm not sure what control you are using to display the data....
    Check out the SqlDataSource Class there are a bunch of tutorials listed on that page....one of which is a Walkthrough on basic data access that I think might help you.

    -Frinny

    Comment

    • markpringle
      New Member
      • Jul 2008
      • 5

      #3
      Originally posted by Frinavale
      I'm not sure what control you are using to display the data....
      Check out the SqlDataSource Class there are a bunch of tutorials listed on that page....one of which is a Walkthrough on basic data access that I think might help you.

      -Frinny
      That's the point. I don't want to use a control to display the data. I just want to use the data to compare to in my code behind. I don't know how (or if it is possible) to access sqldatasource in my code behind.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Originally posted by markpringle
        That's the point. I don't want to use a control to display the data. I just want to use the data to compare to in my code behind. I don't know how (or if it is possible) to access sqldatasource in my code behind.
        There is the alternative if you are not planning to bind the data to a control, you may use a connection, command and data reader in the code behind to obtain the values you want. HTH.

        Comment

        Working...