0

I need to populate the data from database in Dropdown using sqlDataSource. The SqlDataSource is using a querystring. The data is not being populated in dropdown. Can you please suggest what I am doing wrong here?

Code for Dropdown:

<ajaxToolkit:ComboBox ID="SelectDropDown1" runat="server" DropDownStyle="DropDownList"
                    AutoCompleteMode="SuggestAppend" AppendDataBoundItems="true" Width="200px" Height="16pt"
                    Font-Size="8pt"  DataSourceID="SqlDataSource1" DataTextField="Rubric"
                 DataValueField="Rubric">

               <asp:ListItem Value="all">All</asp:ListItem>

                </ajaxToolkit:ComboBox>

Code for SqlDataSource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Education_Data %>"

        SelectCommand="SELECT DISTINCT [Rubric] FROM [table1] WHERE ([Program] = @Program)">

        <SelectParameters>
            <asp:QueryStringParameter Name="Program" QueryStringField="Program" 
                Type="String" />
        </SelectParameters>

    </asp:SqlDataSource>
9
  • Post all code for your SQLDatasource Commented Jun 6, 2013 at 20:22
  • @ user1848739 - editted Commented Jun 6, 2013 at 20:25
  • SELECT DISTINCT [Rubric] FROM [table1] WHERE ([Program] = YourRequestQueryString Run this query to your SQL and see if its returning some values. Also try adding SelectCommandType in your SQLDataSource tag Commented Jun 6, 2013 at 20:26
  • where program='YourRequestQuerystring'. I believe program's datatype is varchar Commented Jun 6, 2013 at 20:37
  • How are you setting the QueryStringParameter? You need to bind it to something or set it somehow using ControlId and PropertyName Commented Jun 6, 2013 at 20:54

1 Answer 1

0

The @program needs to be set somehow.

This MSDN article will show you how to do it. Go to section "Passing Parameters to SQL Statements"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.