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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

122145 Feb 19,2016 10:20 PM UTC Feb 22,2016 12:52 PM UTC ASP.NET Web Forms 1
loading
Tags: ListBox
Jacrys
Asked On February 19, 2016 10:20 PM UTC

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;
            




Kalpana Kandasamy [Syncfusion]
Replied On 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

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.

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

;