We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Example doesn't seem to use 'Selected' variable.

Thread ID:

Created:

Updated:

Platform:

Replies:

144290 Apr 29,2019 10:39 AM UTC Apr 30,2019 09:05 AM UTC ASP.NET Web Forms 1
loading
Tags: DropDownList
Alex Jermy
Asked On April 29, 2019 10:39 AM UTC

Hi,

I am slightly confused by the Syncfusion example provided here:


Where is the 'Selected' variable being used in a SQL query? It doesn't seem to be used in a query anywhere in the example you have provided?

To me it looks like you are assigning the value of the drop down list to a session variable but that variable is not being used anywhere in a SQL 'WHERE' clause?

Thanks,

Alex



Prince Oliver [Syncfusion]
Replied On April 30, 2019 09:05 AM UTC

Hello Alex,  
 
Thank you for contacting us. 
 
Based on your requirement in forum 144217 , we have provided sample to store the selected value from DropDownList in a session variable. Now , we have modified the sample by passing this session variable value through SQL query on button click. The second DropDownList in the page will be populated based on this SQL query. Similarly you can pass query with the session variable and repopulate the charts with user’s selection based on your requirement. Please find the modified code and sample below 
 
<ej:DropDownList runat="server" ID="TradesDropDown" DataTextField="CustomerID" DataValueField="ShipCity" AutoPostBack="true" DataSourceID="SqlData" Width="200px" EnableIncrementalSearch="False" FilterType="Contains" SelectedIndex="0" OnValueSelect="TradesDropDown_ValueSelect"> 
    </ej:DropDownList> 
    <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>" SelectCommand="SELECT * FROM [Orders]"> 
        <SelectParameters> 
            <asp:Parameter Name="ShipCity" Type="String" DefaultValue="Reims" /> 
        </SelectParameters> 
    </asp:SqlDataSource> 
    <ej:Button runat="server" ID="btn" OnClick="btn_Click" Text="Send Query"></ej:Button> 
    <asp:Label runat="server" Text="Items matching the selected ShipCity value will be bound as dataSource of the below DropDownList when send query button is clicked"></asp:Label> 
    <ej:DropDownList runat="server" ID="DropDownList1" DataTextField="CustomerID" DataValueField="ShipCity"> 
    </ej:DropDownList> 
 
Aspx.cs: 
 
protected void TradesDropDown_ValueSelect(object sender, Syncfusion.JavaScript.Web.DropdownListEventArgs e) 
        { 
            Session["ShipCity"] = e.Value; 
        } 
 
        protected void btn_Click(object Sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
        { 
            string selected  = Session["ShipCity"].ToString(); 
            dt = new DataTable("Order"); 
            cmd.Connection = myConnection; 
            cmd.CommandText = "select [CustomerID] from [Orders] where [ShipCity]='" + selected + "'"; 
            cmd.CommandType = CommandType.Text; 
            SqlDataAdapter da = new SqlDataAdapter(); 
            da.SelectCommand = cmd; 
            if ((myConnection.State == ConnectionState.Closed)) 
            { 
                myConnection.Open(); 
            } 
            da.Fill(dt); 
            Session["NewDataSource"] = dt; 
            DropDownList1.DataSource = Session["NewDataSource"];  
        } 
 
 
Let us know if you need any further assistance on this. 
 
Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon