ASP.NET Gridview - 加载时第一行丢失
我使用 ObjectDataSource (应该接收 5 行)和 gridview。 当我打开网格视图时,我收到了除第一行之外的所有行。所以我只看到 4 行。
现在,我通过单击列对网格视图进行排序。但我也只得到 4 行。
选择过滤器后,我收到所有 5 行。
可能是什么问题?
编辑:
<cc1:myGridview ID="mgvTESTs" runat="server" AutoGenerateColumns="False"
DataSourceID="odsTESTs" >
<Columns>
<asp:TemplateField HeaderText="USER" SortExpression="USER">
<ItemTemplate>
<div class="zeile BtnZeile">
<asp:Label ID="lUSER" runat="server" />
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TEST" SortExpression="TEST">
<ItemTemplate>
<asp:Label ID="lTEST" runat="server" Text='<%# Bind("TEST") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bid" SortExpression="BID">
<ItemTemplate>
<asp:Label ID="lBID" runat="server" Text='<%# Bind("BID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DATER" SortExpression="DATER">
<ItemTemplate>
<asp:Label ID="lDATER" runat="server" Text='<%# Bind("DATER") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" SortExpression="ID"
Visible="False" />
</Columns>
</cc1:myGridview>
<asp:ObjectDataSource ID="odsTESTs" runat="server" SelectMethod="SQLSelectQuery"
TypeName="ObjectDataSource_DataBoundControl">
<SelectParameters>
<asp:Parameter Name="SqlCommand" DefaultValue="Select ID,
TEST,
BID,
DATER
FROM
ABC_TESTs
WHERE DATER >= '@param1' AND DATER < '@param2'
ORDER BY DATER DESC" />
<asp:SessionParameter Name="param1" Type="String" DefaultValue="01-01-2011"/>
<asp:SessionParameter Name="param2" Type="String" DefaultValue="01-01-2011"/>
</SelectParameters>
</asp:ObjectDataSource>
I using an ObjectDataSource (Should receive 5 rows) and a gridview.
When I open the gridview I received all rows except the first one. So I only see 4 rows.
Now I sorting my gridview with a click on a column. But I also get only 4 rows.
After selecting a filter I receive all 5 rows.
What could be the problem?
EDIT:
<cc1:myGridview ID="mgvTESTs" runat="server" AutoGenerateColumns="False"
DataSourceID="odsTESTs" >
<Columns>
<asp:TemplateField HeaderText="USER" SortExpression="USER">
<ItemTemplate>
<div class="zeile BtnZeile">
<asp:Label ID="lUSER" runat="server" />
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TEST" SortExpression="TEST">
<ItemTemplate>
<asp:Label ID="lTEST" runat="server" Text='<%# Bind("TEST") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Bid" SortExpression="BID">
<ItemTemplate>
<asp:Label ID="lBID" runat="server" Text='<%# Bind("BID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DATER" SortExpression="DATER">
<ItemTemplate>
<asp:Label ID="lDATER" runat="server" Text='<%# Bind("DATER") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" SortExpression="ID"
Visible="False" />
</Columns>
</cc1:myGridview>
<asp:ObjectDataSource ID="odsTESTs" runat="server" SelectMethod="SQLSelectQuery"
TypeName="ObjectDataSource_DataBoundControl">
<SelectParameters>
<asp:Parameter Name="SqlCommand" DefaultValue="Select ID,
TEST,
BID,
DATER
FROM
ABC_TESTs
WHERE DATER >= '@param1' AND DATER < '@param2'
ORDER BY DATER DESC" />
<asp:SessionParameter Name="param1" Type="String" DefaultValue="01-01-2011"/>
<asp:SessionParameter Name="param2" Type="String" DefaultValue="01-01-2011"/>
</SelectParameters>
</asp:ObjectDataSource>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ObjectDataSource
中的默认选择可能仅返回 4 行,除非您自己在RowDataBound
中对其进行过滤。如果没有像 @Aneef 提到的一些代码,就无法再提供帮助。
The default select in your
ObjectDataSource
is probably only returning 4 rows, unless you are filtering it yourself inRowDataBound
.Can't be of anymore help without some code like @Aneef mentioned.