I am receiving an exception whenever i peform any postback on a page with a grid.
I am adding the grid's column in code and also putting the whole grid into edit mode. The datasource is a datatable. I've been using the examples from the tutorials to get started. I also have 2 linkbuttons in the CommandItemTemplate. Whenever i click on either button, i never back it to the ItemCommand, instead i receive an exception:
DotNetNuke.Services.Exceptions.PageLoadException: Specified argument was out of the range of valid values. Parameter name: index ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: indexat System.Web.UI.ControlCollection.get_Item(Int32 index)at Telerik.Web.UI.GridTextBoxColumnEditor.LoadControlsFromContainer() ...
I can provide the rest of the stack trace if you need.
here is the ascx code:
| <telerik:RadGrid ID="grdProspects" runat="server" AutoGenerateColumns="false" AllowMultiRowEdit="true"> |
| <ClientSettings EnableRowHoverStyle="true"> |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="400" /> |
| </ClientSettings> |
| <MasterTableView EditMode="InPlace" CommandItemDisplay="TopAndBottom"> |
| <CommandItemStyle Height="25px" HorizontalAlign="Right" /> |
| <CommandItemTemplate> |
| <asp:LinkButton ID="lnkAddProspect" runat="server" CommandName="ADD_PROSPECT"><asp:Image ID="imgAddProspect" runat="server" ImageUrl="~/DesktopModules/BAOffice/images/ADD.gif" ToolTip="Add New Prospect" /> Add New Prospect</asp:LinkButton> |
| |
| <asp:LinkButton ID="lnkSaveProspects" runat="server" CommandName="SAVE_PROSPECTS"><asp:Image ID="Image1" runat="server" ImageUrl="~/DesktopModules/BAOffice/images/save.gif" ToolTip="Save Changes" /> Save Changes</asp:LinkButton> |
| |
| </CommandItemTemplate> |
| </MasterTableView> |
| </telerik:RadGrid> |
here is the vb code:
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| If Not IsPostBack Then |
| For Each column As SourceColumn In MyProspectEditor.SourceColumns |
| Dim boundColumn As New GridBoundColumn() |
| boundColumn.DataField = column.Name |
| boundColumn.HeaderText = column.Name |
| boundColumn.ReadOnly = column.IsReadOnly |
| grdProspects.MasterTableView.Columns.Add(boundColumn) |
| Next |
| End If |
| End Sub |
| #Region " Prospects " |
| Private Sub grdProspects_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdProspects.ItemCommand |
| Select Case e.CommandName.ToUpper |
| Case "SAVE_PROSPECTS" |
| Case "ADD_PROSPECT" |
| End Select |
| End Sub |
| Private Sub grdProspects_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdProspects.NeedDataSource |
| If MyProspectEditor IsNot Nothing Then |
| grdProspects.DataSource = MyProspectEditor.GetWorkingData() |
| End If |
| End Sub |
| Private Sub grdProspects_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles grdProspects.PreRender |
| If Not IsPostBack Then |
| For Each item As GridItem In grdProspects.MasterTableView.Items |
| If TypeOf item Is GridEditableItem Then |
| Dim editableItem As GridEditableItem = CType(item, GridDataItem) |
| editableItem.Edit = True |
| End If |
| Next |
| grdProspects.Rebind() |
| End If |
| End Sub |
Any ideas?
thanks!