Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 July 30th, 2008, 11:26 PM
Authorized User
 
Join Date: Aug 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding A Databound Column Dynamically in DataGrid

 i am trying to add column dynamically in Datagrid.

now after creating boundcolumn whenever trying to add it in Datagrid it gives me error of "Object reference not set to an instance of an object." what is wrong with this code?Please Tell me thanks in advance.


 DataSet ds = new DataSet();
   ds = getDataset(); // here Dataset has two column named "ID" and "Name"

   BoundColumn[] name = new BoundColumn[12]; // Array of Bound Column



 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                name[i].HeaderText = Convert.ToString(ds.Tables[0].Rows[i]["Name"]); //Here error Comes

                name[i].DataField = Convert.ToString(ds.Tables[0].Rows[i]["Name"]);
                DataGrid4.Columns.Add(name[i]);
            }







Similar Threads
Thread Thread Starter Forum Replies Last Post
Probelm in DataBound Column of DataGrid su C# 0 December 4th, 2006 08:39 PM
Problem in binding DataBound Column of DataGrid su General .NET 0 December 1st, 2006 02:21 PM
Dynamically adding DataGrid rows lepreston ASP.NET 1.x and 2.0 Application Design 3 November 22nd, 2006 04:33 AM
Dynamically adding Colums to datagrid ? vivekshah C# 0 April 15th, 2006 02:54 AM
Dynamically adding a row to a DataGrid vwindrow ASP.NET 1.x and 2.0 Application Design 2 August 20th, 2003 03:10 PM





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