當我在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