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. Image for the cookie policy date
close icon

ListBox Control not rendering in ASP.NET with Site.Master

I have a page derived from a site.master and the chiled site has a ListBox on it.  The listbox is not rendering, nor populating with the data set.  The data IS being JSON-ified, but the control is not loading it.

The frontend code:
<code
<asp:SqlDataSource ID="Blacklist" runat="server" ConnectionString="<%$ ConnectionStrings:RPM_ReportingConnectionString %>" SelectCommand="SELECT [Email] FROM [vw_Survey_Email_Blacklist]"></asp:SqlDataSource>
    <ej:ListBox ID="BlacklistListBox" runat="server" DataSourceID="Blacklist" DataTextField="Email" DataValueField="Email">
    <Items>
    <ej:ListBoxItems></ej:ListBoxItems>
    </Items>
    </ej:ListBox>
</code>

The Code-Behind:
        protected void Page_Load (object sender, EventArgs e)
        {
            //BlacklistListBox.Items.AddRange (Blacklist.Select (DataSourceSelectArguments.Empty).Cast<ListBoxItems> ());
            BlacklistListBox.LoadDataOnInit = true;
            BlacklistListBox.DataBind ();
            BlacklistListBox.Visible = true;
            BlacklistListBox.Enabled = true;
            




1 Reply

KK Kalpana Kandasamy Syncfusion Team February 22, 2016 12:52 PM UTC

Hi Keith,
Thanks for contacting Syncfusion support.
We have achieved your requirement “render the ListBox from the site.Master file”. If we want to bind the dataSource to the control ,we don’t need to define the listbox items in the View page.

Please refer the below code snippet to render our Listbox component with with SQL datasource.

[view page]

<ej:ListBox ID="DrpDwnsql" runat="server" DataTextField="text" DataValueField="id" DataSourceID="SqlDataSource1"></ej:ListBox>

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT * FROM [Vehicle]" ConnectionString='<%$ ConnectionStrings:Linq_To_SQLConnectionString %>'></asp:SqlDataSource>

 



[code behind]       

        protected void Page_Init(object sender, EventArgs e)

        {

            this.DrpDwnsql.LoadDataOnInit = true;
            this.DrpDwnsql.Enabled = true;
                    }


We have prepared a sample based on your requirement. Please get the sample from below location.

Sample :Listbox

Please let us know if you have any queries.

Regards,
Kalpana K

Loader.
Live Chat Icon For mobile
Up arrow icon