Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2004, 03:56 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to admin@martine.cz Send a message via MSN to admin@martine.cz
Default Programatical insert DataGrid

Hi all,

I have problem with own DataGrid.
In my own CCGrid I inherits base DataGrid and adding them Template Column.
All works OK, bat when I creating DataGrid programmatically, from code in aspx page, the template column is not added to.


Code:
Aspx page:
Code:
CCGrid grid1 = new CCGrid();
grid1.DataSource = GetDataView();
grid1.DataBind();
PlaceHolder1.Controls.Add(grid1);
Cs:
Code:
namespace Test
{
    public class CCGridColumnTemplate : ITemplate
    {
        public void InstantiateIn(Control container) 
        {

            Button btnSelect = new Button();
            btnSelect.Height = 15;
            btnSelect.Width = 15;
            btnSelect.CommandName = "Select";
            btnSelect.Text = " ";
            container.Controls.Add(btnSelect);
        }
    }

    /// <summary>
    /// Summary description for CCGrid.
    /// </summary>
    [DefaultProperty("Text"), 
    ToolboxData("<{0}:CCGrid runat=server></{0}:CCGrid>")]
    public class CCGrid : DataGrid
    {
        /// <summary>
        /// Konstruktor DataGridu: nastavim zakladni vlastnosti
        /// vzhledu a potrebnych sloupcu
        /// </summary>
        public CCGrid()
        {
            //Page.Trace.Write("CCGrid","CCGrid - Start");
            AlternatingItemStyle.BackColor = Color.WhiteSmoke;
            GridLines = GridLines.Both;
            BorderColor = Color.Gray;
            ShowHeader = true;
            AutoGenerateColumns = true;
            SelectedItemStyle.BackColor = Color.Yellow;
            BorderWidth = Unit.Pixel(2);

            SelectedItemStyle.BackColor = Color.Aqua;

            Init +=new EventHandler(OnInit);

            //Page.Trace.Write("CCGrid - End");
        }

        public void OnInit (Object sender, EventArgs e)
        {
//            Page.Trace.Write("CCGrid","OnInit - Start");
            AddSelectColumn();
//            Page.Trace.Write("OnInit - End");
        }


            public void AddSelectColumn()
        {
//            Page.Trace.Write("AddSelectColumn - Start");
            //Add frst Column
            TemplateColumn selectColumn = new TemplateColumn();
                selectColumn.ItemTemplate = new CCGridColumnTemplate();
            Columns.AddAt(0, selectColumn);

        }
    }
}
thanks

Martin





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert from Datagrid sureshaec ASP.NET 2.0 Basics 0 June 6th, 2007 12:30 AM
insert new row in datagrid sumith ASP.NET 1.0 and 1.1 Professional 1 February 15th, 2007 01:53 PM
insert checkbox in datagrid kau_shuk VS.NET 2002/2003 0 November 2nd, 2006 09:32 AM
navigate from one webform to another programatical Abhinav_jain_mca General .NET 2 August 3rd, 2004 03:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.