I assume that you're not getting any data in your grid after you click the
button. Below are your solutions.
Option1:dataGridView1.DataSource = ds;
dataGridView1.DataMember = "Employee"; // name of table
Option2:
dataGridView1.DataSource = Tabe; // set source equal to the actual table
NOTE: If you are clicking the button multiple times, you will need to first
say... dataGridView1.DataSource = null; then say dataGridView1.DataSource =
Table; if the data source wan't null first, it doesn't repopulate, if I
remember correctly, so just set it to null.
On Fri, Sep 5, 2008 at 1:14 PM, asit <[EMAIL PROTECTED]> wrote:
>
> 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
-~----------~----~----~----~------~----~------~--~---