绑定datagridview中的数据 [英] bind the data in datagridview
本文介绍了绑定datagridview中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何绑定datagridview中的数据!
how to bind the data in the datagridview !
推荐答案
将一个datagridview控件拖放到表单中并执行如下操作 -
Drag and drop one datagridview contol to the form and do like this-
private void ShowDetails_Load(object sender, EventArgs e)
{
try
{
SqlConnection sqlconn = new SqlConnection("server=.\\sqlexpress;database=windowform;integrated security=true");
SqlDataAdapter da = new SqlDataAdapter("show", sqlconn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
这篇关于绑定datagridview中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文