this.GridView1.DataBind();是干嘛用的啊? 5
为什么我的VS2010里,找不到这个DataBind()方法啊??那我还能怎么将dataset的数据显示在datagridview里面啊?下面附上代码~!privatev...
为什么我的VS2010里,找不到这个DataBind()方法啊??
那我还能怎么将dataset的数据显示在datagridview里面啊?
下面附上代码~!
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = "Data Source=8BAHAEMRYHWRLHV;Initial Catalog=DIY;Integrated Security=True";
sqlcon.Open();
string str = "select * from Accessories where type='“+combox1.text.trim()+”'";
SqlCommand sqlcom = new SqlCommand(str, sqlcon);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlcom);
da.Fill(ds);
this.dataGridView1.DataSource = ds;
sqlcon.Close();
} 展开
那我还能怎么将dataset的数据显示在datagridview里面啊?
下面附上代码~!
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = "Data Source=8BAHAEMRYHWRLHV;Initial Catalog=DIY;Integrated Security=True";
sqlcon.Open();
string str = "select * from Accessories where type='“+combox1.text.trim()+”'";
SqlCommand sqlcom = new SqlCommand(str, sqlcon);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(sqlcom);
da.Fill(ds);
this.dataGridView1.DataSource = ds;
sqlcon.Close();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询