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.
Risposte
- 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.- Contrassegnato come rispostaHarry ZhuMSFT, Moderatoremartedì 17 novembre 2009 10.18
- Proposto come rispostaHarry ZhuMSFT, Moderatorevenerdì 13 novembre 2009 4.34
Tutte le risposte
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 ;- Contrassegno come risposta annullatoNitin Chaudhary lunedì 9 novembre 2009 7.36
- Contrassegnato come rispostaNitin Chaudhary venerdì 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.- Contrassegnato come rispostaHarry ZhuMSFT, Moderatoremartedì 17 novembre 2009 10.18
- Proposto come rispostaHarry ZhuMSFT, Moderatorevenerdì 13 novembre 2009 4.34

