110,572
社区成员
发帖
与我相关
我的任务
分享
//这个是Demo里面的Load事件代码:
private void DesignerSetupForm_Load(object sender, EventArgs e)
{
// Load the sample data and resize the columns based on their contents.
this.newDataSet.ReadXml(@"..\..\..\..\..\TestData.xml");
this.dataGridView1.AutoResizeColumns();
}
//这个是我自己项目里面的Load事件代码:
strSql = "select top 20 订单编号,贸易方式,价格条款 from dd订单";
SqlDataAdapter dap = new SqlDataAdapter(strSql, clsSql.cn);
DataSet ds = new DataSet();
dap.Fill(ds, "dd订单");
dataGridView1.RowCount = ds.Tables[0].Rows.Count + 1;
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
this.dataGridView1.Rows[j].Cells[0].Value = ds.Tables[0].Rows[j]["订单编号"].ToString();
this.dataGridView1.Rows[j].Cells[1].Value = ds.Tables[0].Rows[j]["贸易方式"].ToString();
this.dataGridView1.Rows[j].Cells[2].Value = ds.Tables[0].Rows[j]["价格条款"].ToString();
}
ds.Dispose();