Try Changing code as below.
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds.Tables[0];
As there are no multiple tables I don't think you need to specify the entire
dataset.
@jamie
Programmers who study language themselves may find some difficulties in the
beginning. Once we only have internet. Now we have mailing lists like this.
If you are an expert and hate these questions, Plz don't react. Only react
to mails u interest. Don't blame him. He may tried his level best. Otherwise
think what he we lazy with this little code. Pasting it in the forum have
the same effort na? If he have to quit from the forum, the forum should have
a welcome message 'Only Advanced Questions Expected' !!!
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of asit
Sent: Saturday, September 06, 2008 12:45 AM
To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting
Subject: [DotNetDevelopment] please fix the following bug
private void button1_Click(object sender, EventArgs e)
{
DataTable Table = null;
DataRow row1 = null;
DataRow row2 = null;
//DataRow row3 = null;
//DataRow row4 = null;
Table = new DataTable("Employee");
DataColumn FirstName = new DataColumn("First Name");
FirstName.DataType = System.Type.GetType("System.String");
Table.Columns.Add(FirstName);
DataColumn Phone = new DataColumn("Phone");
Phone.DataType = System.Type.GetType("System.String");
Table.Columns.Add(Phone);
row1 = Table.NewRow();
row1["First Name"] = "asit";
row1["Phone"] = "9438305868";
Table.Rows.Add(row1);
row2 = Table.NewRow();
row2["First Name"] = "Papu";
row2["Phone"] = "06742302788";
Table.Rows.Add(row2);
DataSet ds = new DataSet();
ds.Tables.Add(Table);
//DataGrid dg = new DataGrid();
//dg.SetDataBinding(ds, "Employee");
dataGridView1.AutoGenerateColumns = true;
dataGridView1.DataSource = ds;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---