![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Display data on DataGridView 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? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Display data on DataGridView "Curious" <fir5tsight@newsgroup> wrote in message news:ca849de8-4756-414c-859e-d03105d04987@newsgroup Quote: > 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? > works with a WinForm(s) application. If you use MSDN (msdn.microsoft.com) to check available methods for the DataGridView class, you'll see that there is no DataBind method. http://msdn.microsoft.com/en-us/libr...rs(VS.80).aspx Further, if you search MSDN for "DataBind method", you'll see only ASP.NET references. To discover the solution you want, you can either find tutorials: http://social.msdn.microsoft.com/Sea...al%20msdn&ac=1 Or, you can create a simple data project using VS' automatic facilities and then observe the generated code. Simply defining a data source and dragging it to an empty form should do what you want. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Microsoft Script Debugger Locals Window Doesn't display VBScript COMobject Data | VB Script | |||
| HTA file - display data from DB records in table like ASP - how? | VB Script | |||
| RE: Data error DataGridView DataGridViewComboBoxColumn | .NET General | |||
| Data Fetching and system.windows.forms.form & .datagridview | PowerShell | |||
| How do I get format-table to drop that omission points (...) and display my data | PowerShell | |||