1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Retreiving a value from one query to pass it to a stored procedure?

Discussion in 'C#' started by binici, Dec 5, 2006.

  1. #1
    Hello! This is driving me crazy. I am having a bit of trouble, when the page loads, I collect a querystring variable from the previous page and pass it through a query to retrieve an office_id, then what I am trying to do is with the value I retrieve is to pass it to another query, which is a stored procedure, so it populates the dropdownlist.

    Here is the code:

    <asp:SqlDataSource ID="sqlBrokersAgentsRecips" runat="server" ConnectionString="<%$ AppSettings:connectionstring %>" ProviderName="System.Data.SqlClient" SelectCommandType="StoredProcedure" SelectCommand="callcenterdev..spGetBrokersAgentsForRecips">
    <SelectParameters>
    <asp:parameter DefaultValue="1" Name="OfficeId" />
    </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="sqlMembersOfficeId" runat="server" ConnectionString="<%$ AppSettings:connectionstring %>" ProviderName="System.Data.SqlClient" SelectCommandType="Text" SelectCommand="SELECT m.Office_Number FROM rapdata..Member m WITH(NOLOCK) WHERE Member_Number = @sesBrokerId">
    <SelectParameters>
    <asp:SessionParameter SessionField="sesBrokerId" Name="sesBrokerId" />
    </SelectParameters>
    </asp:SqlDataSource>

    As you can see I manually add the paramater for the first sqldatasource, which gives me the correct data, but I want to set that parameter to a controlid, or variable if possible, but no luck.

    Thank you for your help.
     
    binici, Dec 5, 2006 IP
  2. Free Born John

    Free Born John Guest

    Messages:
    111
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you'd be better to create a procedure in a class file to call the sp to create and return the dataset and then bind the listbox to that. It gives you much greater flexibility.

    regards

    FBJ
     
    Free Born John, Dec 10, 2006 IP