Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to display empty table to datagrid

Answers were Sorted based on User's Feedback



how to display empty table to datagrid..

Answer / dinesh sharma

DataTable tbl=new DataTable;
DataColumn ID=new
Datacolumn("ID",System.Type.GetType("System.Int"));
DataColumn Name=new
DataColumn("NAME",System.Type.GetType("System.String"));
tbl.Columns.add("ID");
tbl.Columns.Add("NAME");
Datarow dr =null;;
for (int i=0;i<100;i++)
{
dr=tbl.NewRow();
}
datagridview1.datasource=tbl;

Is This Answer Correct ?    14 Yes 1 No

how to display empty table to datagrid..

Answer / neha

DataTable tbl=new DataTable();
tbl.Columns.Add("ID", typeof(int));
tbl.Columns.Add("Name");

datagridview.DataSource=tbl;

Is This Answer Correct ?    1 Yes 0 No

how to display empty table to datagrid..

Answer / radhat

This works, but it only provides one empty row.
It doesn't give you 100 empty rows as your code suggests.
To fix this I added:

dr = tbl.Rows.Add();

right underneath the .NewRow(); line

Hope this helps anyone looking for an empty table.

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More ADO.NET Interview Questions

What is ado in agriculture?

0 Answers  


What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)

0 Answers  


What is the provider and namespaces being used to access oracle database?

5 Answers   E2E, Microsoft,


Where do you store connection string ?

3 Answers   Digital GlobalSoft,


What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database?

0 Answers  


If a table contains 20000 records . In a page at each time 100 records to be displayed what are the steps you will take to improve performance? Will you use dataset or datareader?

0 Answers  


Compare Data Reader & Dataset in ado.net?

0 Answers   MaxSolPro,


What is connection string?

0 Answers  


Is it possible to load multiple tables in a Dataset?

0 Answers  


Differences between dataset.clone and dataset.copy?

2 Answers   Ksb, TCS,


What is ado.net tutorial?

0 Answers  


What is sqldatasource?

0 Answers  


Categories