R.a.d grid compatibility

Posts   
 
    
Ergo_prog
User
Posts: 3
Joined: 19-Aug-2005
# Posted on: 19-Aug-2005 21:06:19   

Hi, I'm having a problem with the R.a.d grid control from Telerik (trial version). The grid is supposed to accept a DataTable as datasource, but when I use GetMultiAsDataTable I get the following error :

"Index was outside the bounds of the array."

GetMultiAsDataTable works well with a basic System.Web.UI.WebControls.DataGrid, so I presume the problem reside with the R.a.d. grid control... Anyone has ever encountered that problem ?

Here's my code :


Private Sub RadGrid1_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        
Dim parts As New TdmPartsCollection

 RadGrid1.DataSource = parts.GetMultiAsDataTable(Nothing, 0, Nothing)

End Sub

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Aug-2005 12:25:27   

You set it in an event handler, shouldn't you set it in a page_load routine? like theGrid.DataSource = myDataTable theGrid.DataBind()

?

Frans Bouma | Lead developer LLBLGen Pro
Ergo_prog
User
Posts: 3
Joined: 19-Aug-2005
# Posted on: 22-Aug-2005 16:03:18   

Well, one of the cool functionnality of the radgrid is precisely that custom event that is trigerred every time the control needs to be binded (on load, etc).

Excerpt from the online radgrid documentation :

NeedDataSource is the event that helps developers control easily scenarios like paging, sorting, grouping, etc. with r.a.d.grid. Those are PostBack events that RadGrid fires that lead to structural change of the Items collections of each GridTableVeiw in r.a.d.grid. A structural change here means that items should be recreated. In order to achieve that r.a.d.grid should have a DataSource assigned and DataBind() method called. Then instead of writing all the code to handle the appropriate scenario the developer can just let r.a.d.grid handle these changes internally and only handle NeedDataSource which fires in the exact moment items should be recreated.

Private Sub RadGrid1_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs)
          Dim MyOleDbConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("Nwind.mdb"))
          Dim MyOleDbDataAdapter As New OleDbDataAdapter
         MyOleDbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Customers", MyOleDbConnection)
          Dim myDataTable As New DataTable
         MyOleDbConnection. Open()
         Try
              MyOleDbDataAdapter.Fill(myDataTable)
          Finally
              MyOleDbConnection. Close()
           End Try
          RadGrid1.DataSource = myDataTable
End Sub

When I use this method it works great, however the grid seems to have a problem to accept a dataTable retreived by using getMultiAsDataTable.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Aug-2005 09:39:35   

Well, GetMultiAsDataTable simply returns a datatable, so that can't be it simple_smile . It could be the index error comes from the fact taht you setup more columns than there are in the datatable?

Frans Bouma | Lead developer LLBLGen Pro
Ergo_prog
User
Posts: 3
Joined: 19-Aug-2005
# Posted on: 23-Aug-2005 16:07:08   

Won't be that neither, because I (shamefully) set the AutoGenerateColumns property of the grid to 'true'.

That error is quite strange, I don't get it with the grids from Dart and ComponentArt.

Emmet
User
Posts: 36
Joined: 12-Jul-2005
# Posted on: 24-Aug-2005 09:47:16   

Ergo_prog wrote:

Won't be that neither, because I (shamefully) set the AutoGenerateColumns property of the grid to 'true'.

That error is quite strange, I don't get it with the grids from Dart and ComponentArt.

What is your opinion on the 3 grids?

I've only used the ComponentArt grid, I know its still beta, but as of now I feel very limited on its functionality. How do the other 2 grids compare?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Aug-2005 09:48:30   

Ergo_prog wrote:

Won't be that neither, because I (shamefully) set the AutoGenerateColumns property of the grid to 'true'. That error is quite strange, I don't get it with the grids from Dart and ComponentArt.

I then have no idea why the exception pops up disappointed . The stacktrace, does it show where exactly the error originates?

Frans Bouma | Lead developer LLBLGen Pro