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

How do u implement locking concept for dataset?

2 Answers   ABC,


What is ado.net architecture?

0 Answers  


Explain how to find the given query is optimised one or not?

0 Answers  


How do you sort the data in datagrid?

4 Answers   Choice Solutions,


The answers which posted above is not satisfied my requirement? Can some one post teh exact answer? Thanx

0 Answers  


What are the different namespaces used in the project to connect the database?

3 Answers  


How to add a javaScript function in a datagrid?

0 Answers   C DAC, CDAC,


OleDbDataAdapter ole=new OleDbDataAdapter(new OleDbCommand ("select * from login",oleDbConnection1)); OleDbCommandBuilder cmd=new OleDbCommandBuilder(ole); ole.Fill(dataSet11,"login"); DataRow drow=dataSet11.Tables ["login"].NewRow(); drow[0]=textBox1.Text; drow[1]=textBox2.Text; drow[2]=textBox3.Text; dataSet11.Tables["login"].Rows.Add (drow); ole.UpdateCommand=cmd.GetUpdateCommand(); ole.Update(dataSet11,"login"); MessageBox.Show("one row added"); this gives exception.how to solve it

1 Answers   Nimaya,


How to call the SQL commands asynchronously in ADO.NET version 2.0

4 Answers   DELL,


Can you explain how to enable and disable connection pooling?

0 Answers  


What is difference between executenonquery and executequery?

0 Answers  


Which parameter of ConnectionString is used to specify the name of the database?

0 Answers  


Categories