当我在datapager中更改页面时,会导致完全回发,即使datapager工作异常,idont知道是什么原因。通过abnormaaly我的意思是某个数据显示的某个时候犯规,
以下是个我的代码在C#listview,datapager,objectdatasource不能在updatepanel中工作
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindListView();
}
}
protected void StudentListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
BindListView();
}
private void BindListView()
{
StudentListView.DataSource = StudentDataSource;
StudentListView.DataBind();
}
protected void StudentDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.Arguments.MaximumRows = StudentListDataPager.MaximumRows;
e.Arguments.StartRowIndex = StudentListDataPager.StartRowIndex;
}
以下是我的标记
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate> <
<asp:DropDownList runat="server" ID="BatchDropDownList" AutoPostBack="True">
<asp:ListItem Text="Batch 1" Value="1" Selected="True" />
<asp:ListItem Text="Batch 2" Value="2" />
</asp:DropDownList>
<asp:ListView ID="StudentListView" runat="server"
ItemPlaceholderID="ListViewContent"
EnableViewState="false"
onpagepropertieschanging="StudentListView_PagePropertiesChanging">
<LayoutTemplate>
<table style="width:100%">
<thead>
<tr>
<th class="align-left"><strong>Name</strong></th>
<th class="align-left"><strong>MobNo</strong></th>
</tr>
</thead>
<tbody runat="server" id="ListViewContent">
</tbody>
<tfoot>
<tr>
<td colspan="3">
</td>
</tr>
</tfoot>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td style="width:70%;"><%# Eval("FirstName") %> <%# Eval("LastName") %></td>
<td style="width:30%;"><%# Eval("MobNo") %></td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="StudentListDataPager" runat="server" PageSize="5" PagedControlID="StudentListView">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
<asp:ObjectDataSource ID="StudentDataSource" runat="server"
SelectMethod="GetStudentListBatchWise" SelectCountMethod="StudentCount"
TypeName="SCERPCommonUtil.Student" EnablePaging="True"
onselecting="StudentDataSource_Selecting">
<SelectParameters>
<asp:ControlParameter Name="batchId" ControlID="BatchDropDownList" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
请告诉我,如果我犯错误。
P.S. :请不要点我任何计算器的问题。我读过所有的人,并没有专门针对我的要求,
我面临的最重要的问题是,DataPager的是充分的回发,即使把datapager
内updatepanel
相同事情发生。
亲爱的你已经指定updatemode为条件。你有提到回发触发到你的更新面板吗? – 2012-07-31 10:22:08
好了 - 用'StudentListDataPager.SetPageProperties(e.StartRowIndex,e.MaximumRows,false);'在'StudentListView_PagePropertiesChanging()'事件中,数据包现在可以正常工作,但仍然存在更新面板的问题,因为守护进程会导致完全回发,我失去了我所有的javascript本地变量。 – j4m4l 2012-07-31 11:01:40