This is a migrated thread and some comments may be shown as answers.

LoadOnDemand Issues

2 Answers 122 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
iomega 55
Top achievements
Rank 1
iomega 55 asked on 05 Apr 2010, 12:34 AM
Hi:

I need to solve this issues on the combobox:

1) When I first load my page, the radcombobox doesnt load any item, it loads them just after the first callback on the page, a callback fired by another control different to the radcombobox. In the first try it shows just the "loading" message but it doesnt return any item.

2) How can I use the onselectindexchanged in the radcombobox using the loadondemand funcionality? I need to load a labels and textboxes after the selectedvalued is changed on the radcombobox, but this event is never fired.

3) I have a master page, in which I have defined a RadScriptManager, RadAjaxLoadingPanel, RadAjaxPanel

4) Inside the RadAjaxPanel, I have a contentplaceholder.

5) In my content pages I have defined a radcombobox like this:
<telerik:RadComboBox ID="cmbUC" runat="server" Height="230px" Width="230px" 
                                                            DropDownWidth="215px" EmptyMessage="Select an UC" HighlightTemplatedItems="true"  
                                                            EnableLoadOnDemand="true" OnItemsRequested="cmbUC_ItemsRequested" ShowWhileLoading="true"
                                                            <HeaderTemplate> 
                                                                <table style="width: 200px" cellspacing="0" cellpadding="0"
                                                                    <tr> 
                                                                        <td style="width: 40px;"
                                                                            Plates</td> 
                                                                        <td style="width: 160px;"
                                                                            UC</td> 
                                                                    </tr> 
                                                                </table> 
                                                            </HeaderTemplate> 
                                                            <ItemTemplate> 
                                                                <table style="width: 200px" cellspacing="0" cellpadding="0"
                                                                    <tr> 
                                                                        <td style="width: 40px;"
                                                                            <%# DataBinder.Eval(Container, "Text")%> 
                                                                        </td> 
                                                                        <td style="width: 160px;"
                                                                            <%# DataBinder.Eval(Container, "Attributes['uc']")%> 
                                                                        </td> 
                                                                    </tr> 
                                                                </table> 
                                                            </ItemTemplate> 
                                                        </telerik:RadComboBox> 
                                                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="cmbUC" 
                                                            ErrorMessage="!" CssClass="validator"
                                                        </asp:RequiredFieldValidator>   

In the server side:
    protected void cmbUC_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) 
    { 
        Tbl01UCCollection _uccollection = new Tbl01UCCollection(); 
 
        _uccollection = cTbl01UC.UnidadCargaCollectionLoadFilter(Convert.ToInt32(Session["sesCompany"]), e.Text); 
 
        foreach (Tbl01UC _uc in _uccollection) 
        { 
            RadComboBoxItem item = new RadComboBoxItem(); 
 
            item.Text = _uc.Plates; 
            item.Value = _uc.Rowid.ToString(); 
 
            item.Attributes.Add("uc", _uc.Descripcion); 
 
            cmbUCItems.Add(item); 
 
            item.DataBind(); 
        } 
    } 

2 Answers, 1 is accepted

Sort by
0
iomega 55
Top achievements
Rank 1
answered on 05 Apr 2010, 04:57 AM
Sorry, I found the error.

Due to the huge viewstate that telerik's controls generate, I add this to the basepage class I used:
    protected override void Render(HtmlTextWriter writer) 
    { 
        StringWriter stringWriter = new StringWriter(); 
        HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); 
        base.Render(htmlWriter); 
 
        string html = stringWriter.ToString(); 
        int StartPoint; 
        int SLength; 
        string ViewStateInput = ""
        StartPoint = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\""); 
        if (StartPoint >= 0) 
        // does __VIEWSTATE exist?   
        { 
            SLength = html.IndexOf("/>", StartPoint) + 2 - StartPoint; 
            ViewStateInput = html.Substring(StartPoint, SLength); 
            html = html.Remove(StartPoint, SLength); 
            int FormEndStart = html.IndexOf("</form>"); 
            html = html.Insert(FormEndStart, ViewStateInput); 
        } 
 
        writer.Write(html); 
    } 
 

This makes my pages display faster even if the viewstate is huge. This code moves the viewstate variable from the top to the bottom of the page.

If I have a radcombobox and in the page  I have more than 10 webcontrols, the first load of the radcombobox returns an error(500 internal server error). So I need a first callback and later the radcombobox works ok.

I deleted these code from my basepage and the radcombobox works in the normal way :) :(

Any comment is welcomed.






0
Simon
Telerik team
answered on 06 Apr 2010, 11:40 AM
Hello iomega 55,

In order to inspect the first issue I tried first recreating it on a page with 10 GridViews and the Render method override you provided. The RadComboBox made its first and all subsequent Load On Demand requests successfully. I attached the test page to this post so that you see it as well. Can you see it and let me know if I am missing something?

Regarding the second issue, you need to set the AutoPostBack property of the RCB to true so that it automatically posts back the page and raise its server-side event.

Greetings,
Simon
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
iomega 55
Top achievements
Rank 1
Answers by
iomega 55
Top achievements
Rank 1
Simon
Telerik team
Share this question
or