查询只返回一行

时间:2015-02-04 06:53:50

标签: asp.net gridview

我在ASPX中有一个项目,现在我必须更新,解决一些问题。我对那种语言的了解不是很高。(但我对其他语言有经验)。

我试图获得结果的Gridview(并理解代码)...

<asp:GridView ID="dvExterneHulp" runat="server" 
        AutoGenerateRows="False" 
        GridLines="None"
        AlternatingRowStyle-CssClass="odd" 
        AllowPaging="true" 
        CssClass="mGrid niceTable"
        OnDataBound="dvExterneHulp_DataBound" 
        PagerStyle-CssClass="pgr" 
        OnPageIndexChanged="gv_PageIndexChanging">
    <AlternatingRowStyle CssClass="odd"></AlternatingRowStyle>
    <Columns>
        <asp:BoundField DataField="HulpverlenerNaam" HeaderText="Naam hulpverlener" />
        <asp:BoundField DataField="HulpverlenerAdres" HeaderText="Adres hulpverlener" />
        <asp:TemplateField HeaderText="Uitleg">
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" 
                    Text='<%# Eval("Uitleg").ToString().Replace("\n", "<br />") %>'
                    Style="word-break: normal; word-wrap: normal;">
                </asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="DatumBegin" HeaderText="Begindatum" DataFormatString="{0:dd/MM/yyyy}" />
        <asp:BoundField DataField="klas_id" HeaderText="Klas" />
        <asp:BoundField DataField="DatumEind" HeaderText="Einddatum" />
    </Columns>
    <PagerStyle CssClass="pgr" />
</asp:GridView>

gv_PageIndexchanging

protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView gv = (GridView)sender;
    gv.PageIndex = e.NewPageIndex;
    gv.DataBind();
}

得到结果

eh = ehs.getLatestData(id, menuitem.Value).FirstOrDefault();
public IQueryable<externehulp> getLatestData(int id, string type)
{
    try
    {
        queryExterne =
            from eh in db.t_eh
            from teh in db.types_eh
            from k in db.klas
            where eh.type_eh == teh.Id
                  && teh.Naam == type
                  && eh.id == id
                  && eh.Klas_id == k.Id
            orderby eh.dateStart, eh.comments descending
            select eh;
    }
    catch
    {
        return null;
    }
    return queryExterne;
}

Externehulp是一个带有一些变量的模型..

Databoundcode

protected void dvExterneHulp_DataBound(object sender, EventArgs e)
{
    //Empty for the moment 
}

但是我收到了错误,我无法找到它的任何含义。
gv_PageIndexChanging没有重载符合委托System.EventHandler

奇怪的是,我在其他网格视图上使用了gv_PageIndexChanging,并且工作正常。

错误是什么意思?也许,我怎么可能解决它?

0 个答案:

没有答案