GridView
- How to bind gridview using connectionstring and select command?
thnx in advanced.
NIIT HOUSE GKP INDIA Please mark the replies as answers if they help and unmark if they don't.
Réponses
- Hi,
You might be more specific about the question.
Do you mean DataGridView control?
What database do you want to connect to?
we can first retrieve the data into a dataset then bind it to datagridview.
Please take a look at the article about how to bind data to the windows forms DataGridView: http://msdn.microsoft.com/en-us/library/fbk67b6z.aspx
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marqué comme réponseHarry ZhuMSFT, Modérateurmardi 17 novembre 2009 10:18
- Proposé comme réponseHarry ZhuMSFT, Modérateurvendredi 13 novembre 2009 04:34
Toutes les réponses
hi...
web application Datagrid
// Setup DB-Connection
ConnectionString = "data source=xeon;uid=sa;password=manager;database=northwind";
SqlConnection cn = new SqlConnection(ConnectionString);
// Create the DataSet
ds = new DataSet("CustOrders");
// Fill the Dataset with Customers, map Default Tablename
// "Table" to "Customers".
SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Customers",cn);
da1.TableMappings.Add("Table","Customers");
da1.Fill(ds);
// Grid Databinding
grdOrders.DataSource = ds.DefaultViewManager ;grdOrders.DataBind();
Data Binding in .NET / C# Windows Forms
// Setup DB-Connection
ConnectionString = "data source=xeon;uid=sa;password=manager;database=northwind";
SqlConnection cn = new SqlConnection(ConnectionString);
// Create the DataSet
ds = new DataSet("CustOrders");
// Fill the Dataset with Customers, map Default Tablename
// "Table" to "Customers".
SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Customers",cn);
da1.TableMappings.Add("Table","Customers");
da1.Fill(ds);
// Grid Databinding
grdOrders.DataSource = ds.DefaultViewManager ;- Non marqué comme réponseNitin Chaudhary lundi 9 novembre 2009 07:36
- Marqué comme réponseNitin Chaudhary vendredi 6 novembre 2009 14:05
- Hi,
You might be more specific about the question.
Do you mean DataGridView control?
What database do you want to connect to?
we can first retrieve the data into a dataset then bind it to datagridview.
Please take a look at the article about how to bind data to the windows forms DataGridView: http://msdn.microsoft.com/en-us/library/fbk67b6z.aspx
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marqué comme réponseHarry ZhuMSFT, Modérateurmardi 17 novembre 2009 10:18
- Proposé comme réponseHarry ZhuMSFT, Modérateurvendredi 13 novembre 2009 04:34

