merge cells in gridview that has same value in asp.net


I have data in following format in gridview

Region Branch Gujrat Ahmedabad Gujrat Surat Gujrat Vadodara Mumbai Dadar Mumbai Andheri Mumbai Borivali

But i want to merge the repeated value like follows

Region Branch Gujrat Ahmedabad Surat Vadodara Mumbai Dadar Andheri Borivali

I am taking data from one table to GridView. In GridView i have TemplateField with Labels which are databound .


You could use <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx" rel="nofollow">RowDataBound</a> to set the Label's Text and check if it's the same as the previous:

protected void Grid_RowDataBound(Object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex > 0) { GridView grid = (GridView)sender; var rowView = (DataRowView)e.Row.DataItem; int lastRowIndex = e.Row.RowIndex - 1; var lastRowView = (DataRowView)grid.Rows[lastRowIndex].DataItem; // replace Region with the correct column name String region = rowView.Row.Field<String>("Region"); String lastRegion = lastRowView.Row.Field<String>("Region"); // replace LblRegion with the correct ID of your Label Label label = (Label)e.Row.FindControl("LblRegion"); label.Text = region != lastRegion ? region : ""; } }


  • How to refresh bindings?
  • DataGridView data-bound to a list is not updated
  • How to show picture that is stored in SQL Server database using ASP.NET?
  • Unable to style borders of a row of Kendo grid
  • ASP GridView Refresh after Excel Export not working
  • Disable gridview link on rows where field is not null?
  • EntityDataSource query inner join
  • gridview rendered in div
  • Bind data to Gridview instance inside ListView ItemDataBound
  • How to change display text in item template based on eval in gridview?
  • Binding a list with another list with WPF
  • “cpanm PHP” fails
  • IE readonly textarea problem
  • Selenium c#: WaitForCondition (how to find when ajax page is fully loaded)
  • How to discover a file is changed in GIT during a push
  • yii2 sorting in related model
  • Migration tool for ANTLR grammar
  • Implementing HMAC-SHA256 for Keybase in Javascript
  • How to Translate texts contained in MsgBox in Inno Setup?
  • Issue with SVN Commit for certain File Extension
  • How Does Navigation in xamarin.forms Works?
  • Checking if the Faye server exists before running it for my Rails app
  • Neo4j: Legacy Indexes and auto index vs new label bases schema indexes
  • Real Time CountDown Timer In Python
  • PyQt4 application on Windows is crashing on exit
  • Backward compatibility of Python 3.5 for external modules
  • Single django queryset to get n adjacent items
  • Retaining data after updating application
  • Activation Function choice for Neural network
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Java color detection
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • Ionic 2 storage is not cleaning up on uninstall - Only for signed APK
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • How to model a transition system with SPIN
  • Updated Ionic CLI but shows previous version (Windows)
  • Unanticipated behavior
  • Comma separated Values
  • Trying to get generic when generic is not available
  • Conditional In-Line CSS for IE and Others?