ASP.Net Merge Data Table with Primary Key and show in Grid
If your rows are appending in 2 data table merge then you must declare a primary key after creating the data table and it will prevent appending the rows of final merge table.
Dim rodt = getDBTable("select hr as Region, count(ro) as c from kpa_forms where del= 0 group by hr")
rodt.PrimaryKey = New System.Data.DataColumn() {rodt.Columns(0)}
Dim mydt = getDBTable("select hr as Region, count(ro) as c from kpa_forms2 where del= 0 group by hr")
mydt.PrimaryKey = New System.Data.DataColumn() {mydt.Columns(0)}
mydt.Merge(rodt)
gvOtherAdmin.DataSource = mydt
gvOtherAdmin.DataBind()
Comments