我有一个listview,它首先填充了3个项目,这是我自己的对象列表。我更改了listview上的数据源,列表中显示了7个项目。当我单击选择项目按钮时,仅显示3个项目。我已经设置了一个寻呼机,但它似乎没有诀窍,数据源在设置时是okey但是当选择的索引发生了某些事情发生了改变但是我对选择的索引的所有cvode如下:
The GridView
<table runat="server">
<tr id="ItemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="TableData">
<td>
<asp:LinkButton ID="LinkButtonClassRegistrationSelection" runat="server" CommandName="Select">
<span>
<b><%# Eval("Name")%></b>
</span>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<SelectedItemTemplate>
<tr class="TableData">
<td class="selectedRow">
<asp:LinkButton ID="LinkButtonClassRegistrationSelection" runat="server" CommandName="Select" CssClass="selectedRow">
<span>
<b><%# Eval("Name")%></b>
</span>
</asp:LinkButton>
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
//This is run with a button on the page
private void UpdateDataSourceForClassRegistrations(List<ClassRegistration> classRegistrationsWithNoResultInCurrentRound, int currentRound)
{
ListViewRound2.DataSource = classRegistrationsWithNoResultInCurrentRound.OrderBy(x => x.StartNumber).ToList();
ListViewRound2.DataBind();
ListViewRound2.SelectedIndex = 0;
ListViewRound2.Visible = true;
}
}
protected void ListViewRound2_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
LabelEkipage.Text = ((List<ClassRegistration>)ListViewRound2.DataSource).Count + "" + DateTime.Now;
ListViewRound2.DataSource = ((List<ClassRegistration>)ListViewRound2.DataSource).ToList();
ListViewRound2.SelectedIndex = e.NewSelectedIndex;
ListViewRound2.DataBind();
}