how to calculate data based on Active and Inactive conditions.

sorry if my english is not good..

i am new to using syncfusion in creating my learning project with winForms.

i want to count the number of active and inactive students from sfDatagrid and display the result in label control. how to achieve that ?


3 Replies

VS Vijayarasan Sivanandham Syncfusion Team August 30, 2022 02:33 PM UTC

Hi Ridwan,

Your requirement to calculate data based on Active and Inactive conditions and display the result in label control can be achieved by using View.GetPropertyAccessProvider method in SfDatGrid. Please refer to the below code snippet,


private void btnGetCount_Click(object sender, EventArgs e)

{

 

            if (sfDataGrid1.View != null)

            {

                var provider = this.sfDataGrid1.View.GetPropertyAccessProvider();

                //here check the underline record that contains the Active and Inactive value in GridColumn

 

                //here get the Active records count in SfDataGrid

                var getActiveRecords = this.sfDataGrid1.View.Records.Where(x => provider.GetValue(x.Data, "Status").ToString() == "Active");

                //here get the InActive records count in SfDataGrid

                var getInActiveRecords = this.sfDataGrid1.View.Records.Where(x => provider.GetValue(x.Data, "Status").ToString() == "Inactive");

 

                //here display the Active records count in label

                lblActiveCount.Text = "Active Records Count is : " + getActiveRecords.Count();

                //here display the InActive records count in label

                lblInActiveCount.Text = "InActive Records Count is : " + getInActiveRecords.Count();

            }

}


Please find the sample in the attachment and let us know if you have any concerns in this.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: Sample_f7299db0.zip


RI RIDWAN replied to Vijayarasan Sivanandham September 12, 2022 08:20 AM UTC

Sorry for the delay in this response..

I just wanted to thank you for your reply.. it's really helpful. and have a nice day sir :)



SJ Sathiyathanam Jeyakumar Syncfusion Team September 13, 2022 12:03 PM UTC

Hi Ridwan,


We are glad to know that the provided solution has been worked at your end. Please let us know if you have any further queries on this. We are happy to help you.😊


Regards,

Sathiyathanam


Loader.
Up arrow icon