C
Curious
I'll need to display data in a grid on a Windows Form, call it
"frmGrid". Since I cannot find "GridView" in the Toolbox, I pick
"DataGridView" instead (call it "dataGridView1"). I have the code
below:
mConnection = new SqlConnection("Data
Source=Westwind;Initial Catalog=db_dynamic_trading;Integrated
Security=True;");
mConnection.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter
("db_dynamic_trading.dbo.emily_get_records", mConnection);
da.SelectCommand.CommandType =
CommandType.StoredProcedure;
da.Fill(ds);
frmGrid fGrid = new frmGrid(da); // Call constructor
below to connect dataGridView1 with da
fGrid.Show();
In constructor for frmGrid, I have the code below to connect
dataGridView1 with da:
public frmGrid(SqlDataAdapter da)
{
InitializeComponent();
this.dataGridView1.DataSource = da;
this.dataGridView1.DataBind();
}
Now the code cannot even compile because it complains that
'System.Windows.Forms.DataGridView' does not contain a definition for
'DataBind'.
Any advice on how to get this fixed?
"frmGrid". Since I cannot find "GridView" in the Toolbox, I pick
"DataGridView" instead (call it "dataGridView1"). I have the code
below:
mConnection = new SqlConnection("Data
Source=Westwind;Initial Catalog=db_dynamic_trading;Integrated
Security=True;");
mConnection.Open();
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter
("db_dynamic_trading.dbo.emily_get_records", mConnection);
da.SelectCommand.CommandType =
CommandType.StoredProcedure;
da.Fill(ds);
frmGrid fGrid = new frmGrid(da); // Call constructor
below to connect dataGridView1 with da
fGrid.Show();
In constructor for frmGrid, I have the code below to connect
dataGridView1 with da:
public frmGrid(SqlDataAdapter da)
{
InitializeComponent();
this.dataGridView1.DataSource = da;
this.dataGridView1.DataBind();
}
Now the code cannot even compile because it complains that
'System.Windows.Forms.DataGridView' does not contain a definition for
'DataBind'.
Any advice on how to get this fixed?