【发布时间】:2012-08-14 22:36:25
【问题描述】:
我正在将一堆代码从 vb.net 转换为 c#,但我不太了解 vb.net,所以遇到了很多问题。
谁能帮我看看这里出了什么问题?
protected void GenerateSalaryPunchesTable()
{
this.dgvPunchs.Rows.Clear();
string[] DateRange = this.cboPayPeriods.SelectedItem.Text.ToString().Replace(" ", "").Split('-');
while (Convert.ToDateTime(DateRange[0]) <= Convert.ToDateTime(DateRange[1]))
{
if (Convert.ToDateTime(DateRange[0]).DayOfWeek != DayOfWeek.Saturday & Convert.ToDateTime(DateRange[0]).DayOfWeek != DayOfWeek.Sunday)
{
Infragistics.WebUI.UltraWebGrid.UltraGridRow nRow = new Infragistics.WebUI.UltraWebGrid.UltraGridRow();
nRow.Cells.Add();
// Date Cell
nRow.Cells.Add();
// Worked CB
nRow.Cells.Add();
// Vacation CB
nRow.Cells.Add();
// Sick CB
nRow.Cells.Add();
// Holiday CB
nRow.Cells.Add();
// Error
nRow.Key = Convert.ToDateTime(DateRange[0].ToString()).ToShortDateString();
nRow.Cells[0].Value = Convert.ToDateTime(DateRange[0].ToString()).ToShortDateString();
nRow.Cells[1].Value = 0;
nRow.Cells[2].Value = 0;
nRow.Cells[3].Value = 0;
nRow.Cells[4].Value = 0;
nRow.Cells[5].Value = "";
this.dgvPunchs.Rows.Add(nRow);
}
DateRange[0] = Convert.ToDateTime(DateRange[0]).AddDays(1);
}
}
这是它给我的错误:
错误 4 'Infragistics.Web.UI.GridControls.ControlDataRecordCollection.Add(Infragistics.Web.UI.GridControls.ControlDataRecord)' 的最佳重载方法匹配有一些无效参数
错误 5 参数 1:无法从“Infragistics.WebUI.UltraWebGrid.UltraGridRow”转换为“Infragistics.Web.UI.GridControls.ControlDataRecord”
这里是控件:
<ig:WebDataGrid ID="dgvPunchs" runat="server" Height="350px" Width="400px">
</ig:WebDataGrid>
它是从 VB.net 和旧版本的 Infragistics 转换而来的。到目前为止,我无法弄清楚。
编辑:
我试过了,还是不行……
Infragistics.Web.UI.GridControls.ControlDataRecord nRow =
Infragistics.Web.UI.GridControls.ControlDataRecord();
//Infragistics.WebUI.UltraWebGrid.UltraGridRow nRow = new Infragistics.WebUI.UltraWebGrid.UltraGridRow();
【问题讨论】:
-
异常中不明显吗?您正在尝试将
UltraGridRow添加到ControlDataRecord对象的集合中... -
我认为错误发生在这个地方
this.dgvPunchs.Rows.Add(nRow);你正在添加一行并且 dgvPunchs 接受 controldatarecord -
可能是新版本的基础设施改变了它的实现,所以现在它不是一个 UltraGridRow,而是一个 ControlDataRecord。我会看看他们文档中的任何重大更改。 C# 版本是否按原样工作?换句话说,它可能与您转换为 VB.NET 无关
-
@JeffMercado 我是 100% 的基础设施新手,以前从未使用过它们。你知道我怎么能解决这个问题。我试图添加代码(编辑了 OP),但没有奏效。我理解错误,只是不知道如何解决它。
-
@SimonMartin 是的,到目前为止我很茫然。叹息。
标签: c# asp.net infragistics webdatagrid