我有一个带有下拉列表列的gridview,并且我启用了分页功能。问题是每次翻到下一页后,上一页下拉列表的选中值又回到默认值。
我试图用 包装代码if(!ispostback)
,只有可用的第一页其他页面消失了
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<CPDEmployee> employeelist = (List<CPDEmployee>)Cache["EmployeeList"];
unverifiedlist.DataSource = employeelist;
unverifiedlist.AllowPaging = true;
unverifiedlist.PageSize = 10;
unverifiedlist.DataBind();
}
}
protected void PageSelect_SelectedIndexChanged(object sender, EventArgs e)
{
int page = int.Parse(PageSelect.SelectedItem.Text);
unverifiedlist.PageIndex = page;
DataBind();
}
<asp:GridView ID="unverifiedlist" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" ViewStateMode="Enabled">
<Columns><asp:TemplateField HeaderText="Options" >
<ItemTemplate>
<asp:DropDownList ID="options" runat="server" AutoPostBack="true">
<asp:ListItem Value="1">Verified</asp:ListItem>
<asp:ListItem Value="0">Rejected</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Visible="false"/>
</asp:GridView>
<asp:DropDownList ID="PageSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageSelect_SelectedIndexChanged"></asp:DropDownList>
有谁知道如何解决它,我应该把ispostback放在哪里?谢谢