initialization radDropDownList after update a record in the table

1 Answer 55 Views
DropDownList
Laurent
Top achievements
Rank 1
Iron
Iron
Laurent asked on 21 Aug 2024, 01:21 PM

Hi,

I have an RadDropDownList filled with some record of a table (ttSoc) using DataSource and bounded functionality.

I have a button that lets me add/delete records from this table (ttsoc).
Impossible to update the RadDropDownList

 

my code:

in the form load I run ChargeCodeSociete('InitBe').

In the click button  I run ChargeCodeSociete('affiche').

METHOD PRIVATE VOID BtnSociete_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):

// On instancie la classe
        oFrmSociete = NEW frmSociete().
        // En attente du retour de la form en mode dialog box
        WAIT-FOR oFrmSociete:ShowDialog().

oongDescriptionEtudeGeneral:ChargeCodeSociete('Affiche').

RETURN.

END METHOD.

 

IN oongDescriptionEtudeGenral FORM

METHOD PUBLIC VOID ChargeCodeSociete( INPUT ipcMode AS CHARACTER ):
        CASE ipcMode:
            WHEN 'InitBe' THEN DO:
                beSociete= NEW fichier.description_etude.be.beSociete().

                beSociete:ReadbeSociete(OUTPUT DATASET dsSoc).

                //Associer le query du dataset au probadingSource
                bsSociete:HANDLE = DATASET dsSoc:HANDLE.
            END.
            WHEN 'Affiche' THEN DO:
                DATASET dsSoc:TOP-NAV-QUERY():QUERY-PREPARE("FOR EACH ttSoc").
                DATASET dsSoc:TOP-NAV-QUERY():QUERY-OPEN().   


                DropDownListCodeSociete: ?????

            END.
        END CASE.

 

thank you for your feedback

                                                                                              

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Aug 2024, 08:46 AM

Hello Laurent,

I will start with the fact that I am not fully familiar with the code syntax here. In general, the control will not automatically get the data from the updated SQL DataTable. To test your case, I have follow a similar approach as demonstrated in the Tutorial: Binding to MS Access DataTable/Database help article for the RadGridView. I have created a demo table in my SQL server using the following code:

CREATE TABLE Local_Database.[dbo].[DemoTable]  
( 
  Id INT IDENTITY, 
  Company VARCHAR(100),
  NetWorth BIGINT
);
GO  

INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('Apple', 1);  
INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('Microsoft', 2);  
INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('Saudi Arabian Oil Company', 3);
INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('Amazon', 4); 
INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('Alphabet', 5); 
GO  

SELECT * FROM Local_Database.[dbo].[DemoTable]  
GO

This produced the following table in SQL Management Studio:

Then I added an adapter to my project and filled it with the data. You are right that updating a recorded or adding a new one will not automatically update the DataSet. This behavior is not directly related to our controls. If you are executing logic that update the DataTable, you can update the dataset by forcing to get the DataTable from the server again. I have tested this by updating by adding a record in SQL Management Studio using the following code while the application is running:

  INSERT INTO Local_Database.[dbo].[DemoTable]   VALUES ('222222', 33);  

Then on a button click I get the table again:

Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
    Me.DemoTableTableAdapter.Fill(Me.AdventureWorksDataSet.DemoTable)
End Sub

I am attaching my test project here. The project is in VB, but the code in Form1.vb is pretty simple and I think you can get the idea. I hope that you can use a similar approach on your side.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Laurent
Top achievements
Rank 1
Iron
Iron
commented on 03 Sep 2024, 01:36 PM

Merci pour votre retour.

Entre temps j'ai trouvé la solution.

 

Thanks for your feedback, in the meantime I've found the solution.

Tags
DropDownList
Asked by
Laurent
Top achievements
Rank 1
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or