Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:54:30+00:00 2026-06-16T00:54:30+00:00

Here’s a dropdown list I have… <asp:DropDownList ID=selectTimeFrame runat=server AutoPostBack=true DataTextField=Increment DataValueField=Increment DataSourceID=SqlTimeFrame </asp:DropDownList>

  • 0

Here’s a dropdown list I have…

<asp:DropDownList
    ID="selectTimeFrame"
    runat="server"
    AutoPostBack="true"
    DataTextField="Increment"
    DataValueField="Increment"
    DataSourceID="SqlTimeFrame" 
</asp:DropDownList>

And its datasource:

  <asp:SqlDataSource 
    ID="SqlTimeFrame"
    runat="server"
    ConnectionString="<% connectionstring %>"
    SelectCommand="Select [IncrementID], [Increment] FROM [TimeFrame] ORDER BY [IncrementID]" >
</asp:SqlDataSource>

and then I have a gridview, whos datasource looks like:

 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<% connectinstring %>"
    ProviderName="<% connectionstring %>"
    SelectCommand="SELECT * FROM @TimeFrame">

    <SelectParameters>
        <asp:ControlParameter ControlID="selectTimeFrame"
            Name="TimeFrame"
            PropertyName="SelectedValue"
            Type="String" />
    </SelectParameters>

And obviously the place where I’m having problems is the fact that ” FROM @TimeFrame ” doesn’t do what I want to. I have Different views whose names correspond to different timeframes, and I want to be able to change the gridview to populate with that information based off of the option a user selects via the dropdown menu. Any insight would be much appreciated… THANKS!! 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:54:31+00:00Added an answer on June 16, 2026 at 12:54 am

    You could use dynamic SQL to achieve what you’re looking for although you would need to test this very thorughly to prevent SQL injection attacks as we can never trust the input being received from users.

    I’ve created a simple stored proc which checks whether the table exists in the db and if so it constructs and executes your dynamic SQL statement:

    Stored procedure:

    CREATE PROCEDURE dbo.GetData
    @TableName NVARCHAR(200)
    AS
    BEGIN
    IF OBJECT_ID(@TableName , N'U') IS NOT NULL
        BEGIN 
            EXEC('SELECT * FROM ' + @TableName);
        END
    END
    

    ASPX:

    <asp:DropDownList ID="selectTimeFrame" runat="server" AutoPostBack="true" DataTextField="Increment"
        DataValueField="Increment" DataSourceID="SqlTimeFrame" />
    <asp:SqlDataSource ID="SqlTimeFrame" runat="server" ConnectionString="<%$ ConnectionStrings:connectionstring %>"
        SelectCommand="Select [IncrementID], [Increment] FROM [TimeFrame] ORDER BY [IncrementID]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dynamicDS" runat="server" ConnectionString="<%$ ConnectionStrings:connectionstring %>"
        SelectCommand="GetData" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="selectTimeFrame" Name="TableName" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="gvData" DataSourceID="dynamicDS" runat="server">
    </asp:GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is the two scripts I have Script 1: <? include('config.php'); $json = $_POST['payload'];
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
Here is what I want to do. Use this HTML line and have the
Here's the setup - I have a view that lists products. On that same
Here's the link: www.mchenry.edu/maps/google.asp Why won't the location balloon display correctly? Also, the pop-up
Here's my situation. I have a DotNetNuke application. I want to link to an
Here is a scenario: User installs .NET application that you have made. After some
Here is my problem: I have a chatapplication and the messages are displayed in
Here is my code for the POST request to the server. The JSON to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.