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