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

RadGrid demo code

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clarence
Top achievements
Rank 1
Clarence asked on 21 Jan 2014, 12:31 AM
Hi,

I'm looking at the demo code for RadGrid (http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultvb.aspx)

and when I try to run it, I get a System.ArgumentOutOfRangeException error on:

    Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) Handles RadGrid1.PreRender
        If Not IsPostBack Then
            Me.RadGrid1.MasterTableView.Items(1).Edit = True <-- this line is throwing the error
            Me.RadGrid1.MasterTableView.Rebind()
        End If
    End Sub

I haven't modified any of the demo code, and wondering how to fix this.

Thanks in advance.



1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Jan 2014, 05:08 AM
Hello,

Please try with the below code snippet.

Protected Sub Page_PreRender(sender As Object, e As EventArgs)
    If IsPostBack = False AndAlso Me.RadGrid1.MasterTableView.Items.Count > 0 Then
        Me.RadGrid1.MasterTableView.Items(0).Edit = True
        Me.RadGrid1.MasterTableView.Rebind()
    End If
End Sub

At initial page load your grid have do not have any record that's why it throw the error.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Clarence
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or