I am trying to create a simple grd that will take a programmatically generated datatable and allow sorting in a usercontrol that is used in DotNetNuke.
My code:
Private dt As DataTable
Private WithEvents RadGrid1 As RadGrid
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dt = New DataTable()
dt.Columns.Add("PMID")
dt.Columns.Add("BioText")
dt.Columns.Add("Version")
dt.Columns.Add("PMCID")
dt.Columns.Add("ManuscriptID")
dt.Columns.Add("DOI")
dt.Columns.Add("pii")
dt.Columns.Add("Authors")
dt.Columns.Add("ISOAbbreviation")
dt.Columns.Add("Year")
RadGrid1 = New RadGrid
RadGrid1.AutoGenerateColumns = True
RadGrid1.DataSource = dt
RadGrid1.AllowSorting = True
RadGrid1.Skin = "Outlook"
PlaceHolder1.Controls.Add(RadGrid1)
End Sub
Then I create the datatable from data that I get from a webservice.
however when I click the column to sort all of the data disappears as if the Grid does not have any data source. I then added:
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = GetDataTable("")
End Sub
Public Function GetDataTable(ByVal query As String) As DataTable
Return dt
End Function
but that does not seem to help. I've searched the forums for hours but it seems that I cannot find a total solution. I'm not sure if I need to wrap my placeholder in a panel or not. All help is appreciated.
Thanks