Jump to content
Software FX Community

Template column causing problems


vaioklm

Recommended Posts

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
Link to comment
Share on other sites

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

 

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...