Articles in this section
Category / Section

How to navigate to an URL when tapping on a cell in .NET MAUI DataGrid (SfDataGrid)?

2 mins read

The .NET MAUI DataGrid allows you to navigate to a URL upon tapping a grid cell using the CellTapped event. The DataGridCellTappedEventArgs provides the RowColumnIndex of the tapped cell, enabling you to navigate to the desired URL based on the argument values.

Refer to the code example below to navigate to a URL when the first cell of the record is tapped.

Behavior:
protected override void OnAttachedTo(SfDataGrid dataGrid)
{
  dataGrid.CellTapped += DataGrid_CellTapped;
  base.OnAttachedTo(dataGrid);
}

private void DataGrid_CellTapped(object? sender, DataGridCellTappedEventArgs e)
{
  if (e.RowColumnIndex.RowIndex == 1 && e.RowColumnIndex.ColumnIndex == 0)
  {
      Uri uri = new Uri("https://help.syncfusion.com/");
      Launcher.TryOpenAsync(uri);
  }
}

protected override void OnDetachingFrom(SfDataGrid dataGrid)
{
  dataGrid.CellTapped -= DataGrid_CellTapped;
  base.OnDetachingFrom(dataGrid);
} 

Download the complete sample from GitHub

Conclusion

I hope you enjoyed learning how to navigate to a URL when tapping on a cell in .NET MAUI DataGrid (SfDataGrid).

You can refer to our .NET MAUI DataGrid feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI DataGrid Documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components on the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI DataGrid and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac or feedback portal, or the 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