This is a migrated thread and some comments may be shown as answers.

Grid disappears

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 25 Sep 2011, 02:18 AM

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

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 26 Sep 2011, 04:11 PM
Hello William,

I would recommend that you examine the following links:
Programmatic Creation demo / On PageLoad
Programmatic Creation help topic (Creating RadGrid on Page_Load)

Regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
William
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or