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.
Respostas
- 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.- Marcado como RespostaHarry ZhuMSFT, Moderadorterça-feira, 17 de novembro de 2009 10:18
- Sugerido como RespostaHarry ZhuMSFT, Moderadorsexta-feira, 13 de novembro de 2009 4:34
Todas as Respostas
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 ;- Não Marcado como RespostaNitin Chaudhary segunda-feira, 9 de novembro de 2009 7:36
- Marcado como RespostaNitin Chaudhary sexta-feira, 6 de novembro de 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.- Marcado como RespostaHarry ZhuMSFT, Moderadorterça-feira, 17 de novembro de 2009 10:18
- Sugerido como RespostaHarry ZhuMSFT, Moderadorsexta-feira, 13 de novembro de 2009 4:34

