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

Rebind Radcombobox with new values on clientclose

6 Answers 146 Views
Window
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 10 Apr 2015, 06:21 AM

Hi All,

Here's my issue, I have a parent form that has a bounded radcombobox, a grid that get bind from the radcombobox and a button that open a radwindow.

The radwindow contains only one textbox with a save button.

The scenario should be as follow once you open the radwindow, enter a new value in the textbox and save. the popup should be close then do a postback and rebind the radcombobox that is in the parent form so that the new values are available.

Can somebody help me.

Thanks in advance.

 

6 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 10 Apr 2015, 02:15 PM

Hi Christian,

The following demo shows one way to do that: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window. You only need to define the required AJAX settings and the rebinding logic in the AjaxRequest event.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Christian
Top achievements
Rank 1
answered on 13 Apr 2015, 09:42 AM

Hi Marin.

Thanks for the reply, I know how to rebind a radgrid and that works like a charm in my project,

My issue comes when I need to rebind a radcombobox when radwindow get closed and do a postback so that the new values that in the DB get load into the Radcombobox.

I have tried the following codes but with no luck:

JS:

function closeRadwindow() {
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
        }

VB:

Private Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
         cmbCategory.DataBind()
     End Sub

 

ASPX:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">  

   <AjaxSettings>     

    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  

           <UpdatedControls>  <telerik:AjaxUpdatedControl ControlID="cmbCategory" />    

         </UpdatedControls>         </telerik:AjaxSetting>     </AjaxSettings> </telerik:RadAjaxManager> 

 after doing all the postback is performed but the radwindow does not close anymore(its keeps on poping up.)

 

0
Marin Bratanov
Telerik team
answered on 16 Apr 2015, 08:13 AM

Hi Christian,

Can you confirm there are no script errors or server-side errors thrown? This is the most likely reason for either issue at this point.

Server-side errors thrown during an AJAX request are shown as JS errors, so you would need to examine the browser console and/or step through the server code to ensure the new data is present in the combo box as desired. With the available code snippets I do not see a new data source being provided to the combo box, so it should be expected to keep the old one.

As for the RadWIndow closing - make sure you have a call to its close() method, as I am not sure how is the closeRadwindow() function called. The following article will show you how to get the needed reference: http://www.telerik.com/help/aspnet-ajax/window-client-side-basics.html.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Christian
Top achievements
Rank 1
answered on 16 Apr 2015, 08:48 AM

 Hi Marin

 Yes there are no errors scripts error that I can see at present time.

as per your reply, the closeRadwindow() function is being called on the OnClientClose method of the radwindow.

concerning the combo box I do not see the reason of providing a new datasource to it as it already bound to a datasource, so I believe by calling a rebind will automatically reload the datasource to which the combo box is bound and reload it with new values.(can be correct if my statement is wrong.)

if possible can you show me a portion of code that can achieve what I want to do.

 

0
Marin Bratanov
Telerik team
answered on 16 Apr 2015, 11:12 AM

Hi Christian,

To be honest, at this point I am not completely sure what you are trying to achieve. If you want to keep the same data source in the combo box, why is an AJAX request needed and why would you want to rebind it?

If you provide a programmatic data source to the combo, here is one way to change it:

RadComboBox1.DataSource= null;
RadComboBox1.DataSource = someObject;
RadComboBox1.DataBind();

If you are using a declarative DataSource (like SqlDataSource), just make sure it returns the expected data after calling the DataBind() method.

To further troubleshoot the issue, I advise that you post here the simplest code that shows the problem you are having so I can look into it. Otherwise, I would need to continue guessing, which is not very effective.

Regards,

Marin Bratanov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Pabitra
Top achievements
Rank 1
answered on 03 Oct 2016, 04:14 PM

Hello,

I tried following with following code but it didn't work for me.

            string sqlQuery = string.Format("SELECT {0} FROM {1} WHERE {2} = '{3}' AND {4} = '{5}' AND {6} like '{7}'",
                                              DBConst.PhraseMaster_PhraseID, DBConst.Table_PhraseMaster, DBConst.PhraseMaster_Language,
                                              configItemValue, DBConst.PhraseMaster_Status, "A", DBConst.PhraseMaster_PhraseID, szLongDesc);

            DataTable dt = DatabaseGateway.ExecuteDataset(ConnectionType.HazoxWeb, sqlQuery).Tables[0];                
            if (dt != null && dt.Rows.Count > 0)
            {
                ddlHazard.DataSource = null;
                ddlHazard.DataSource = dtHAZ;
                ddlHazard.DataTextField = DBConst.PhraseMaster_PhraseID;
                ddlHazard.DataValueField = DBConst.PhraseMaster_PhraseID;
                ddlHazard.DataBind();
            }

I verified that dt not null and dt.Rows.Count greater than zero.

Regards,

Pabitra

Tags
Window
Asked by
Christian
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Christian
Top achievements
Rank 1
Pabitra
Top achievements
Rank 1
Share this question
or