DataSet ds=clientPrint.GetOrder(User.UserName,User.UserPass);
dgOrder.DataSource = ds.Tables[0].DefaultView;
像如果是WebForm的话我只要在DataGrid的模版中改就可以了
但是WinForm的我实在不知道在哪里改比如我有数据User Pass Name
Admin 123 小张我要绑定后为
用户名 密码 姓名
Admin 123 小张而我现在绑定的话只能为上面的那种样式谢谢
调试欢乐多
SqlConnection Conn = new SqlConnection();
Conn.ConnectionString = "server=(local);Database=test;uid=sa;pwd=test";
Conn.Open();
DataSet ds = new DataSet();
SqlDataAdapter DP = new SqlDataAdapter("select top 10 * from table", Conn);
DP.Fill(ds, "table");
DP.Dispose();
Conn.Close();
Conn.Dispose();
ds.Tables[0].DefaultView.AllowDelete = true;
dataGridView1.AutoGenerateColumns = false;
DataGridViewTextBoxColumn colName = new DataGridViewTextBoxColumn();
colName.Name = "PKID";
colName.HeaderText = "PKID";
colName.DataPropertyName = "PKID";
this.dataGridView1.Columns.Add(colName); DataGridViewTextBoxColumn colName1 = new DataGridViewTextBoxColumn();
colName1.Name = "SALES";
colName1.HeaderText = "SALES";
colName1.DataPropertyName = "SALES";
this.dataGridView1.Columns.Add(colName1); dataGridView1.DataSource = ds.Tables[0];//.DefaultView;//设置DataGrid的数据源