in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Setting a C1TemplateColumn's EditItemTemplate at runtime

Last post 12-14-2007 1:15 PM by C1_GregL. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12-14-2007 8:51 AM

    Setting a C1TemplateColumn's EditItemTemplate at runtime

    Hi,

    I am trying to change at run the way a template column's items are edited.
    I tried this without success:

    protected void OnGridPreRender(object sender, EventArgs e)
    {
            ((C1.Web.C1WebGrid.C1TemplateColumn) wgGrid.Columns[3]).EditItemTemplate = LoadTemplate("ValidateEditTemplate.ascx");
            wgGrid.DataBind();
    }

     

    ValidateEditTemplate.ascx:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ValidateEditTemplate.ascx.cs" Inherits="ValidateEditTemplate" %>
    <asp:DropDownList ID="status" runat="server">
    <asp:ListItem>Your choice?</asp:ListItem>
    <asp:ListItem>Accepted</asp:ListItem>
    <asp:ListItem>Not accepted</asp:ListItem>
    </
    asp:DropDownList>
    <asp:textbox ID="Textbox8" runat="server" Text='<%# Bind("Value") %>' width="40px" />

     

    Is it anything I'm missing here?

    Thanks in advance for any help!

    Eric

     

    NB: I think the ascx is valid since it works when I copy it in the <EditItemTemplate> tag of the grid.

  • 12-14-2007 1:15 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 500

    Re: Setting a C1TemplateColumn's EditItemTemplate at runtime

    I think you just need to add this line after you load the template

    ...column.EditItemTemplate.InstantiateIn(C1WebGrid1)

    hope that does it

    -Greg

     

Page 1 of 1 (2 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.