When i change the page in datapager it causes full postback, even the datapager is working very abnormally, idont know what is the reason. by abnormaaly i mean sometime data is shown sometime doesnt,
Following is th my code in c#
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;
}
Following is my markup
<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>
Please tell me if i am making any mistakes.
P.S. : Please dont point me to any stackoverflow question as i have read all of them, and none is specific to my requirement,
Most important problem i am facing is that datapager is giving full postback, even if put datapager
inside updatepanel
same thing happens.
StudentListDataPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
inStudentListView_PagePropertiesChanging()
event, the datapager now works fine, but still the problem of update panel stands as daemon, which causes full postback, and i lose all my javascript local variable.