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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update cell value in new row ?

Thread ID:

Created:

Updated:

Platform:

Replies:

146837 Aug 22,2019 08:56 AM UTC Sep 23,2019 10:02 AM UTC WinForms 4
loading
Tags: SfDataGrid
Cosyspro
Asked On August 22, 2019 08:56 AM UTC

Hello Syncfusion,
SfDataGrid has two columns (GridTextColumn and GridButtonColumn).
In the SfDataGrid_CellButtonClick, I allow user to select a file from openFileDialog control and then I set Cell value of the GridTextColumn to the path of selected file.
This works fine for the added rows but not for the new row.

How can I access to cell of the adding new row for updating its contnent ?

Best regards

Farjana Parveen Ayubb [Syncfusion]
Replied On August 23, 2019 10:33 AM UTC

Hi Cosyspro, 
 
Thank you for using Syncfusion support. 
 
By default, CellButtonClick event is raise for GridButtonColumn in AddNewRow, so you can set the value for the GridTextColumn in CellButtonClick event by using SetValue method in PropertyAccessProvider. It’s set the value for both DefaultRow and AddNewRow. 
 
Please refer the below code example 
 
sfDataGrid.CellButtonClick += SfDataGrid_CellButtonClick; 
private void SfDataGrid_CellButtonClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellButtonClickEventArgs e) 
{ 
    var fileContent = string.Empty; 
    var filePath = string.Empty; 
 
    using (OpenFileDialog openFileDialog = new OpenFileDialog()) 
    { 
        openFileDialog.InitialDirectory = "c:\\"; 
        openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; 
        openFileDialog.FilterIndex = 2; 
        openFileDialog.RestoreDirectory = true; 
 
        if (openFileDialog.ShowDialog() == DialogResult.OK) 
        { 
            filePath = openFileDialog.FileName; 
            sfDataGrid.View.GetPropertyAccessProvider().SetValue((e.Record as Syncfusion.WinForms.DataGrid.DataRow).RowData, "FilePath", filePath); 
        } 
    } 
 
 
 
 
 
Please let us know if you need any further details on this. 
 
Regards,
Farjana Parveen A
 


Cosyspro
Replied On August 23, 2019 05:33 PM UTC

Dear Farjana,
Thank you for your response and I appreciate your help.

Your solution does not work when I click on "Click here to add new row" and then I click directly on Button. An exception is generated "(e.Record as Syncfusion.WinForms.DataGrid.DataRow).RowData == null".

However, it works when I double click or edit FilePath Cell before click on Button.

Question: Why the display text of the Button is empty after click on "Click here to add new row" and it appears after edit or double click PathFile Cell?

Regards

Farjana Parveen Ayubb [Syncfusion]
Replied On August 26, 2019 12:37 PM UTC

Hi Cosyspro, 
 
Thank you for your update, please refer the below response. 
 
Why the display text of the Button is empty after click on "Click here to add new row" 
The cell values for the AddNewRow will be initialized only when the AddNewRow is initialized. AddNewRow initialization will be triggered only when any of the cell in AddNewRow starts editing. 
Display text appears after edit or double click PathFile Cell? 
Here, the AddNewRow will be initialized and the display text for button is appeared properly. 
 
We are considering this behavior as a bug and we have logged a report on this. The fix for the reported issue will be included in our upcoming Volume 3 release which may expected to roll out on end of September 2019. 
 
Also we have created feedback link for the reported issue and we request you to login to the below link to view further 
 
 
Note: The provided feedback link is private, and you need to login to view this feedback. 
 
Regards,  
Farjana Parveen A 


Farjana Parveen Ayubb [Syncfusion]
Replied On September 23, 2019 10:02 AM UTC

Hi Cosyspro, 
 
We are glad to announce that our Essential Studio 2019 Volume 3 Beta Release version 17.3.0.9 is rolled out with the reported issue fix “Cell buttons are loaded in add new row improperly before add new row is initialized” and is available for download under the following link. 
 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Farjana Parveen A 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon