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

  • SEARCH
  • Home
  • 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 6349727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:40:21+00:00 2026-05-24T21:40:21+00:00

I’m working on making customized gridviews with the use of dropdownlist and checkboxes. The

  • 0

I’m working on making customized gridviews with the use of dropdownlist and checkboxes. The checkboxes represent the columns in the database to call. My codebehind file is to create a customized SQL Query that I call back to the asp:DqlDataSource… SelectCommand=””

As of now I’m trying to store a message into (query) into a variable, this is where I’m currently stuck…

<asp:DropDownList ID="DDL" runat="server" DataSourceID="SqlDataSource1" 
        DataTextField="Fullname" DataValueField="Employee_ID"  AutoPostBack="true">
    </asp:DropDownList> 
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DBConnectionString %>" 
        SelectCommand="@Query">
    </asp:SqlDataSource>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
    <asp:CheckBox ID="Address" Text="Address" runat="server" />
    <asp:CheckBox ID="Phone" Text="Phone" runat="server" />
    <asp:CheckBox ID="Email" Text="Email" runat="server" />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="ButtonID"  onclick="Create" runat="server" Text="Submit" />
    <br />
    <br />
    <br />
    <br />
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label> -
    <asp:Label ID="Label2" runat="server" Text=""></asp:Label> -
    <asp:Label ID="Label3" runat="server" Text=""></asp:Label> -
    <asp:Label ID="Label4" runat="server" Text=""></asp:Label> -
    <br />
    <asp:Label ID="Label5" runat="server" Text=""></asp:Label>
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>

======================= CodeBehind ===========================

protected void Create(object sender, System.EventArgs e)
{

    string a = "";
    string b = "";
    string c = "";
    string d = "";

    if (DDL.SelectedValue == "Select")
    {
        return;
    }
    else
    {
        a = DDL.SelectedValue;
    }
    if (Address.Checked == true)
    {
        b = "Address,";

    }

    if (Phone.Checked == true)
    {
        c = "Phone,";

    }

    if (Email.Checked == true)
    {
        d = "Email,";

    }

        Label1.Text = a;
        Label2.Text = b;
        Label3.Text = c;
        Label4.Text = d;
        string Query = ("SELECT" b c d "FROM Employee WHERE Employee_ID =" a);    
}
  • 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-05-24T21:40:22+00:00Added an answer on May 24, 2026 at 9:40 pm

    What exactly is the issue you’re running in to?

    I would guess that you’re having an issue running that query because it’ll have a comma before FROM. A better way to hold the fields you want to search on might be to push the values into a single array and then loop through the contents of the array and separate each by a comma. That way your list of fields can grow and shrink to any size without worrying about empty values. You also might want to consider wrapping the “a” value in single quotes (assuming you’re reading in strings…)

    Old code:

    string Query = ("SELECT" b c d "FROM Employee WHERE Employee_ID =" a); 
    

    Result: *SELECT Address,Phone,Email,FROM Employee WHERE Employee_ID = Bob Jones*

    New code:

    string Query = "SELECT " + String.Join(", ", arrFields) + " FROM Employee WHERE Employee_ID = '" + a + "'"
    

    Result: *SELECT Address, Phone, Email FROM Employee WHERE Employee_ID = ‘Bob Jones’*

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:

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.