【发布时间】:2016-05-26 10:46:05
【问题描述】:
我从 sql server 数据库中检索数据并将数据填充到数据表中(结果有 4 行)。然后与datagridview绑定。它创建了四行,但都有空单元格。
绑定代码
dt = newconnection.selectcommand("Select row_number() over(order by Join_Date) as sno , Employee_Name as empname, REPLACE(CONVERT(CHAR(11), Join_Date, 106) ,' ','-') as doj,'" + billing_month + "' as \"billingmonth\" ," + noofdaysmonth + " as daysofmonth ,'" + attndperiod + "' as period, Rate as rate, 0 as billabledays from Employee_For_Customer where Customer_Name = '" + CmbCustomer.Text + "'");
DgvEmployee.AutoGenerateColumns = false;
DgvEmployee.DataSource = dt;
【问题讨论】:
-
检查here
-
@shadow 我做了同样的事情......当检查 datagridview.datasource 它显示所有行时。但它在控件中显示空单元格。
-
删除预先设计的列,然后重试。
标签: c# sql-server datagridview datatable