Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 3rd, 2004, 04:53 AM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add rows to DataGrid with AutoGenerateColumns=Fals

Hi,
i have datagrid with defined template columns but i can't add any rows to it.
I tried

        ICollection CreateDataSource()
        {
            DataTable dt = new DataTable();
            DataRow dr;

            dt.Columns.Add(new DataColumn("Èçáîð", typeof(bool)));
            dt.Columns.Add(new DataColumn("Êîä", typeof(string)));

            for (int i = 0; i < 2; i++)
            {
                dr = dt.NewRow();

                dr[0] = true;
                dr[1] = "011235"+i.ToString();

                dt.Rows.Add(dr);
            }

            DataView dv = new DataView(dt);
            return dv;
        }

and then

            DataGrid1.DataSource = CreateDataSource();
            DataGrid1.DataBind();

but it seems is not working. There is two rows added in the grid but the rows are empty(no values). If i switch on AutoGenerateColumns it's ok but i need template columns so AutoGenerate must be disabled. I don't have any database behind so i must populate the DataGrid with some way like this above.

 
Old February 3rd, 2004, 07:49 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What does the <columns> portion of your datagrid markup look like?
 
Old February 3rd, 2004, 08:46 AM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 What does the <columns> portion of your datagrid markup look like?
something like this:
 <Columns>
     <asp:TemplateColumn HeaderText="Èçáîð">
        <ItemTemplate>
       <asp:CheckBox id="cbIzbor" runat="server"></asp:CheckBox>
        </ItemTemplate>
     </asp:TemplateColumn>
     <asp:BoundColumn HeaderText="Êîä"></asp:BoundColumn>

 </Columns>

there is more columns but these are that i tried to fill first.

 
Old February 3rd, 2004, 10:26 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The template column won't populate without a DataField specified.

Provide a DataField="<column name>" attribute in the <asp:TemplateColumn...>.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Rows to Grid View dpkbahuguna ASP.NET 1.x and 2.0 Application Design 0 March 19th, 2008 04:05 AM
Add&Remove rows from DB using listbox martinhogan VB Databases Basics 3 September 11th, 2006 06:24 AM
how to add rows to the child grid Amorous ASP.NET 1.0 and 1.1 Basics 1 January 12th, 2006 06:44 PM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Professional 0 March 13th, 2005 04:30 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Basics 0 March 13th, 2005 04:28 AM





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