C# GridView-仅在第二页中超出范围
我正在尝试传递行的索引…它工作得很好…但是我的gridview启用了分页功能,例如,当我在第二页中使用索引时,我得到了超出范围的错误…但是我收到的索引是正确的。例如..我第一页有4行,第二页有4行..如果我点击第二页的第一项,我得到了索引5…这是正确的。我有8个ITEN…为什么索引5超出了范围 这是我的密码:C# GridView-仅在第二页中超出范围,c#,asp.net,gridview,C#,Asp.net,Gridview,我正在尝试传递行的索引…它工作得很好…但是我的gridview启用了分页功能,例如,当我在第二页中使用索引时,我得到了超出范围的错误…但是我收到的索引是正确的。例如..我第一页有4行,第二页有4行..如果我点击第二页的第一项,我得到了索引5…这是正确的。我有8个ITEN…为什么索引5超出了范围 这是我的密码: <asp:GridView ID="GridView1" runat="server" CellPadding="4" BorderStyle="None
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
BorderStyle="None" BorderWidth="0px" CellSpacing="1" Width="100%"
GridLines="Vertical" AllowPaging="True" onrowcommand="GridView1_RowCommand"
onselectedindexchanged="GridView1_SelectedIndexChanged"
onpageindexchanging="GridView1_PageIndexChanging"
onrowdatabound="GridView1_RowDataBound" PageSize="5" HorizontalAlign=Left
>
<PagerStyle HorizontalAlign="Center" />
<RowStyle CssClass="tabela_texto2" HorizontalAlign="Center"
VerticalAlign="Middle" />
<AlternatingRowStyle CssClass="tabela_texto1" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Status" CommandName="atender" CommandArgument='<%# Container.DataItemIndex %>' ID="atender" runat="server" OnClientClick="return confirm('Tem certeza que deseja aterar os status?');" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Ver no mapa" CommandName="ver" CommandArgument='<%# Container.DataItemIndex %>' ID="ver" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Excluir" CommandName="excluir" CommandArgument='<%#((GridViewRow)Container).RowIndex%>' ID="excluir" runat="server" OnClientClick="return confirm('Tem certeza que deseja aterar os status?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
这可能是一个解决办法:
int index = int.Parse(e.CommandArgument.ToString()) % GridView1.PageSize
这可能是一个解决办法:
int index = int.Parse(e.CommandArgument.ToString()) % GridView1.PageSize
这可能是一个解决办法:
int index = int.Parse(e.CommandArgument.ToString()) % GridView1.PageSize
这可能是一个解决办法:
int index = int.Parse(e.CommandArgument.ToString()) % GridView1.PageSize
由于
行[索引]
或单元格[3]
?请记住,索引是网格中的行的索引,而不是整个分页集合中元素的索引。问题在于没有第四个单元格。请尝试使用单元格[2]
。此处可能需要类似于索引%pageSize
的内容。@选择单元格的数量与第一页相同……原因是行[index]
或单元格[3]
?请记住,索引是网格中的行的索引,而不是整个分页集合中元素的索引。问题在于没有第四个单元格。请尝试使用单元格[2]
。此处可能需要类似于索引%pageSize
的内容。@选择单元格的数量与第一页相同……原因是行[index]
或单元格[3]
?请记住,索引是网格中的行的索引,而不是整个分页集合中元素的索引。问题在于没有第四个单元格。请尝试使用单元格[2]
。此处可能需要类似于索引%pageSize
的内容。@选择单元格的数量与第一页相同……原因是行[index]
或单元格[3]
?请记住,索引是网格中的行的索引,而不是整个分页集合中元素的索引。问题在于没有第四个单元格。请尝试使用单元格[2]
。此处可能需要类似于索引%pageSize
的内容。@选择单元格的数量与第一页相同。。。。