小编Mar*_*ius的帖子

C#Foreach语句不包含GetEnumerator的公共定义

我正在使用C#构建的Windows窗体应用程序出现问题.该错误表明"foreach语句不能对'CarBootSale.CarBootSaleList'类型的变量进行操作,因为'CarBootSale.CarBootSaleList'不包含'GetEnumerator'的公共定义".

我似乎无法理解造成这种情况的原因.

这是抛出错误的代码:

        List<CarBootSaleList> Sortcarboot = new List<CarBootSaleList>();

        foreach (CarBootSale c in carBootSaleList)
        {
            if (c.Charity == "N/A")
            {
                Sortcarboot.Add(carBootSaleList);
                textReportGenerator.GenerateAllReport(Sortcarboot, AppData.CHARITY);
            }
        }
Run Code Online (Sandbox Code Playgroud)

这是CarBootSaleList类,它说没有GetEnumerator定义:

public class CarBootSaleList
{

    private List<CarBootSale> carbootsales;

    public CarBootSaleList()
    {
        carbootsales = new List<CarBootSale>();
    }

    public bool AddCarBootSale(CarBootSale carbootsale)
    {
        bool success = true;
        foreach (CarBootSale cbs in carbootsales)
        {
            if (cbs.ID == carbootsale.ID)
            {
                success = false;
            }
        }
        if (success)
        {
            carbootsales.Add(carbootsale);
        }
        return success;
    }

    public void DeleteCarBootSale(CarBootSale carbootsale)
    {
        carbootsales.Remove(carbootsale);
    } …
Run Code Online (Sandbox Code Playgroud)

c# public definition enumerator

22
推荐指数
4
解决办法
13万
查看次数

如何使用 Jquery 获取 Gridview 行值

当我们点击更新按钮时,我需要得到

日期、客户名称、小时数、费率、表格日期、截止日期、增值税、服务税、总金额详情..

使用“Jquery”

请帮助我....

我非常感谢你......

    <asp:GridView ID="gvTransactions" CssClass="gridStyle" runat="server" AutoGenerateColumns="false" 
DataKeyNames="fn_transaction_pk"
OnRowDataBound="gvTransactions_RowDataBound"
OnRowDeleting="gvTransactions_RowDeleting"
OnRowEditing="gvTransactions_RowEditing"
OnRowCancelingEdit="gvTransactions_RowCancelingEdit" >
<Columns>
<asp:TemplateField HeaderText="Invoice Details" ItemStyle-Width="90%" >
<ItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:HiddenField ID="fn_transaction_pk" runat="server" value='<% #Eval("FN_TRANSACTION_PK")%>' />
<asp:Label ID="lblDate" runat="server" Text="Date : " CssClass="gridLabel1Style" />
</td>
<td><asp:Label ID="ltDate" runat="server" Text='<% #Eval("transaction_date","{0:MM/dd/yyyy}")%>' CssClass="gridLadel2Style" /></td>
</tr>
<tr>
<td><asp:Label ID="lblClientName" runat="server" Text="Client Name : " CssClass="gridLabel1Style"/></td>
<td><asp:Label ID="ltClientName" runat="server" Text='<% #Eval("CLIENT_NAME") %>' CssClass="gridLadel2Style" /></td>
</tr>
<tr>
<td><asp:Label ID="lblNoOfHours" runat="server" Text="Number of Hours : " CssClass="gridLabel1Style" /></td> …
Run Code Online (Sandbox Code Playgroud)

asp.net jquery

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1

definition ×1

enumerator ×1

jquery ×1

public ×1