vaioklm Posted February 13, 2008 Report Posted February 13, 2008 I create a template column with the following code: Dim tcTemplateColumn As New GridFX.WebForms.TemplateColumntcTemplateColumn.Title = "Template Test"Dim itTest As New itTestTemplatetcTemplateColumn.ItemTemplate = itTestColumns.Add(tcTemplateColumn) The template is very basic. It does nothing more than create a literal containing the word "Test". The grid will initially render fine and I see my template column as expected. However, if I attempt to Sort, Group, Hide a Column, etc... (essentially anything that causes a callback), the Grid goes out to lunch and I eventually get a window asking if I'd like to continue waiting. If something causes the entire page to postback, I get the following error: [ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index] System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) +62 System.ThrowHelper.ThrowArgumentOutOfRangeException() +12 System.Collections.Generic.List`1.get_Item(Int32 index) +2583412 cq.c() +101 cq.e() +167 cq.r() +24 cq.a(Grid A_0) +34 GridFX.WebForms.TemplateColumn.e() +88 GridFX.WebForms.GridColumn.a(Grid A_0) +34 GridFX.WebForms.GridColumnCollection.b(GridColumn A_0) +96 GridFX.WebForms.GridColumnCollection.d(GridColumn A_0) +31 GridFX.WebForms.ObservableList`1.Add(T item) +164 GridFX.WebForms.GridColumnCollection.b(lq A_0) +201 GridFX.WebForms.Grid.b(lq A_0) +87 GridFX.WebForms.Grid.c(Object A_0) +115 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +251 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +142 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +300 System.Web.UI.Page.LoadAllState() +520 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3444
AngelR Posted February 15, 2008 Report Posted February 15, 2008 Try this: Create the TemplateColumn inside the Init Event. Let me know if this helps.
vaioklm Posted February 18, 2008 Author Report Posted February 18, 2008 It didn't seem to make a difference. If I moved the entire block of code to the Init, the column didn't show on the grid. When I left the Columns.Add in the Databinding Event and moved the rest to the Init, it rendered ok, but still behaved the same on callbacks or postbacks.
AngelR Posted February 19, 2008 Report Posted February 19, 2008 Following is a sample code showing how to render a .Net Textbox inside a Template Column. Note how the class implementing an Itemplate Interface (TemplateColumn) is called from the Grid_Init Event. Also note how we fill every Item Cell Textbox in the Template Column with calculated data from others cells. Remember to use latest Hotfix. Let me know if this helps. protected void Grid1_Init(object sender, EventArgs e) {String HeaderText = "Agent Full Name"; GridFX.WebForms.TemplateColumn tc = new GridFX.WebForms.TemplateColumn(); tc.HeaderTemplate = new ColumnTemplate(HeaderText); tc.ItemTemplate = new ColumnTemplate("");Grid1.Columns.Add(tc); }--------------------------------------------------------------------------------------------------------------------------------- protected void Grid1_Rendering(object sender, EventArgs e) { foreach (GridItem item in Grid1.Items) { TextBox TextBox3 = (TextBox)item.Cells[4].FindControl("TextBox1"); TextBox3.Text = item.Cells[2].Text + " " + item.Cells[3].Text; } } -------------------------------------------------------------------------------------------------------------------------------------- public class ColumnTemplate : ITemplate {private String m_StringText1;public ColumnTemplate(String StringText1) {this.m_StringText1 = StringText1; }#region ITemplate Memberspublic void InstantiateIn(Control container) { TextBox Text1 = new TextBox();Text1.ID = "TextBox1"; Text1.Text = m_StringText1; Text1.ReadOnly = true;Text1.Enabled = false; container.Controls.Add(Text1); }#endregion }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.