Need help to re-load data after postback

2 posts, 0 answers
  1. Helen
    Helen avatar
    42 posts
    Member since:
    Nov 2013

    Posted 09 Oct 2014 Link to this post

    Hi,I have created a button to simulate clicking the arrow on a combobox.
    Basically I hide the combobox and call the javascript to triggers the dropdown behavior of the combobox when a user clicks on the button.
    The user will be able to select an item from the dropdown and then the code-behind will populate the selected address into the textboxes accordingly.Everything works ok up to this point. The problem starts after the postback, data in the dropdown list is gone.
    I found a few posts on the forum which says we need to load the data on each post back or in the ItemsRequested event but that didn't work for me.
    I must be missing something obvious, but just can't spot it.  Please help~

    javascript :
         Since the combobox is in a user control, I load the javascript using ScriptManager.

    protected void Page_Load(object sender, EventArgs e)
        //  Load script dynamically for user control
        StringBuilder script = new StringBuilder();
        script.Append("function ShowDropDownFunction() {");
        script.Append("var combo = $find('" + RadLogixBuildingComboBox.ClientID + "');");
        script.Append("combo.showDropDown(); }");
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "script1", script.ToString(), true);
        SALTLeadDetailsBLL _detailBLL = new SALTLeadDetailsBLL();
        SALTLeadDetailsDAL.sbms_bldgDataTable dt = _detailBLL.GetLogixBuildings(SalesID);
        RadLogixBuildingComboBox.DataSource = dt;
    protected void RadLogixBuildingComboBox_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        DataRowView dataItem = (DataRowView)e.Item.DataItem;
        e.Item.Text = dataItem["bldgstreet1"].ToString().Trim() + "; " + dataItem["bldgcity"].ToString().Trim() + "; " + dataItem["bldgstate"].ToString().Trim() + "; " + dataItem["bldgzip"].ToString().Trim() + "; " + dataItem["market"].ToString().Trim();
        e.Item.Value = dataItem["bldgstreet1"].ToString().Trim() + "; " + dataItem["bldgcity"].ToString().Trim() + "; " + dataItem["bldgstate"].ToString().Trim() + "; " + dataItem["bldgzip"].ToString().Trim() + "; " + dataItem["market"].ToString().Trim();
    protected void RadLogixBuildingComboBox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        //  When loadondemand is turned on, SelectedItem is not available :
        //  Use e.item.text and e.item.value in ItemDataBound event
        String selectedItemValues = RadLogixBuildingComboBox.SelectedValue;
        List<string> itemValues = selectedItemValues.Split(';').ToList();
        string[] zipCode = itemValues[3].Trim().Split('-');
        string zip = zipCode[0].ToString().Trim();
        string zipExt = zipCode[1].ToString().Trim();
        Address1TextBox.Text = itemValues[0].ToString().Trim();
        CityTextBox.Text = itemValues[1].ToString().Trim();
        StateTextBox.Text = itemValues[2].ToString().Trim();
        ZipTextBox.Text = zip;
        ZipExtTextBox.Text = zipExt;
        RadMarketComboBox.SelectedValue = itemValues[4].ToString().Trim();
    protected void RadLogixBuildingComboBox_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        SALTLeadDetailsBLL _detailBLL = new SALTLeadDetailsBLL();
        SALTLeadDetailsDAL.sbms_bldgDataTable dt = _detailBLL.GetLogixBuildings(SalesID);
        RadLogixBuildingComboBox.DataSource = dt;

    ascx :

    <telerik:RadButton ID="LogixBuildingImageButton" AutoPostBack="false" runat="server"  Image-ImageUrl="~/images/building16.png" ToolTip="Logix Buildings" Width="16px" Height="16px" OnClientClicked="ShowDropDownFunction" />
    <telerik:RadComboBox ID="RadLogixBuildingComboBox" runat="server" AutoPostBack="true"   MarkFirstMatch="false" ItemsPerRequest="5" ShowMoreResultsBox="true"
            EnableAutomaticLoadOnDemand="true" EnableVirtualScrolling="true"
            DropDownAutoWidth="Disabled" DropDownWidth="700px" Width="0" Height="150px" HighlightTemplatedItems="true"  EnableScreenBoundaryDetection="true"
            OnItemDataBound="RadLogixBuildingComboBox_ItemDataBound"  OnSelectedIndexChanged="RadLogixBuildingComboBox_SelectedIndexChanged" OnItemsRequested="RadLogixBuildingComboBox_ItemsRequested" >
                    <td class="logixbuildingcol1">Building Street</td>
                    <td class="logixbuildingcol2">City</td>
                    <td class="logixbuildingcol3">State</td>
                    <td class="logixbuildingcol4">Zip</td>
                    <td class="logixbuildingcol5">Status</td>
                    <td class="logixbuildingcol6">Address Type</td>
                    <td class="logixbuildingcol1"><%# DataBinder.Eval(Container.DataItem, "bldgstreet1") %> </td>
                    <td class="logixbuildingcol2"><%# DataBinder.Eval(Container.DataItem, "bldgcity") %></td>
                    <td class="logixbuildingcol3"><%# DataBinder.Eval(Container.DataItem, "bldgstate") %></td>
                    <td class="logixbuildingcol4"><%# DataBinder.Eval(Container.DataItem, "bldgzip") %></td>
                    <td class="logixbuildingcol5"><%# DataBinder.Eval(Container.DataItem, "buildingStatus") %></td>
                    <td class="logixbuildingcol6"><%# DataBinder.Eval(Container.DataItem, "addressTypeDesc") %></td>
                    <td class="logixbuildingcol1"><telerik:RadButton ID="RadCloseButton" runat="server" AutoPostBack="false" Text="Close" Icon-PrimaryIconUrl="~/images/exit_16x16.png" OnClientClicking="HideDropDownFunction()" /></td>

    Thank you,


  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 10 Oct 2014 Link to this post

    Hi Helen,

    From the provided code snippets I could not determine what might be causing that issue.
    It is possible to open a new support ticket and send me runnable sample project which reproduces the problem.
    Do you reproduce the issue when the AJAX is turned off?

    Peter Filipov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top