Articles in this section
Category / Section

How to get the row details on tapping a row in MAUI DataGrid (SfDataGrid)?

3 mins read

The .NET MAUI DataGrid (SfDataGrid) , you can get the RowData while tapping a row by using the SfDataGrid.CellTapped event. It provides the RowData in its argument. Thus, using the RowData you can get the Row Details of the tapped cell in SfDataGrid.

Refer the below code example in which the CellTapped event is hooked in SfDataGrid.

 

XAML

<ContentPage.BindingContext>
        <local:EmployeeViewModel x:Name="viewModel"/>
    </ContentPage.BindingContext>
 
    <syncfusion:SfDataGrid x:Name ="dataGrid"
                    ItemsSource="{Binding Employees}" CellTapped="dataGrid_CellTapped">
    </syncfusion:SfDataGrid>

 

C#

private void dataGrid_CellTapped(object sender, Syncfusion.Maui.DataGrid.DataGridCellTappedEventArgs e)
    {
        var empdata = (Employee)e.RowData;
        DisplayAlert("Setected Row Data",
            "Employee ID        : " + empdata.EmployeeID.ToString() +
            "\nEmployee Name    : " + empdata.Name.ToString() +
            "\nID Number        : " + empdata.IDNumber.ToString() +
            "\nTitle            : " + empdata.Title.ToString() +
            "\nContact ID       : " + empdata.ContactID.ToString() +
            "\nBirth Date       : " + empdata.BirthDate.ToString(“d”) +
            "\nMarital Status   : " + empdata.MaritalStatus.ToString() +
            "\nGender           : " + empdata.Gender.ToString() +
            "\nHire Date        : " + empdata.HireDate.ToString(“d”) +
            "\nSick Leave Hours : " + empdata.SickLeaveHours.ToString() +
            "\nSalary           : " + empdata.Salary.ToString() +
            "\nLogin ID         : " + empdata.LoginID.ToString() +
            "\nManager ID       : " + empdata.ManagerID.ToString() +
            "\nEmployee Status  : " + empdata.EmployeeStatus.ToString() +
            "\nRating           : " + empdata.Rating.ToString(),
            "Cancel");
    }

 

how to get row data by tapping the row

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

View Sample on GitHub

Take a moment to pursue this documentation, where you can find more about Syncfusion .NET MAUI DataGrid (SfDataGrid) with code examples.

Please refer to this link to learn about the essential features of Syncfusion .NET MAUI DataGrid (SfDataGrid).

Conclusion

I hope you enjoyed learning about how to get Row details by tapping a row in MAUI DataGrid (SfDataGrid).

You can refer to our .NET MAUI DataGrid’s feature tour page to know about its other groundbreaking feature representations. You can also explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.

For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI DataGrid and other .NET MAUI components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied