我有一個列表視圖與刪除網格說我有一個頁面上的分頁鏈接(前1 2下一個)。當我試圖刪除第二頁中的最後一條記錄時,listview不會顯示出來。我已經在服務器端進行了綁定,並在記錄刪除時調用。如果第二頁有兩個以上的記錄,則表示網格。任何人都知道爲什麼會出現這個問題?但是當我重新加載網頁顯示。列表視圖不顯示當最後一個記錄刪除使用asp.net
我有一個列表視圖網格,
<asp:ListView ID="lvSurvey" runat="server" GroupPlaceholderID="groupPlaceHolder2"
ItemPlaceholderID="itemPlaceHolder2" OnPagePropertiesChanging="OnPagePropertiesChangingSurvey" OnItemCommand="lvSurvey_ItemCommand" >
---
--
</asp:ListView>
我也有分頁作爲
<asp:PlaceHolder runat="server" ID="groupPlaceHolder2"></asp:PlaceHolder>
<tr>
<td colspan = "3">
<asp:DataPager ID="DataPager2" runat="server" PagedControlID="lvSurvey" PageSize="1">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="false" ShowPreviousPageButton="true"
ShowNextPageButton="false" />
<asp:NumericPagerField ButtonType="Link" />
<asp:NextPreviousPagerField ButtonType="Link" ShowNextPageButton="true" ShowLastPageButton="false" ShowPreviousPageButton = "false" />
</Fields>
</asp:DataPager>
</td>
</tr>
我能夠在頁面中顯示從SQL Server記錄並分頁顯示。我在網格中的刪除按鈕
<asp:LinkButton ID="lnkDelete" runat="server" CssClass="btn btn-danger" OnClientClick="return getConfirmation(this, 'Please confirm','Are you sure you want to delete?');" CommandArgument='<%# Eval("Order_Survey_ID") + "|" + Eval("Status") %>'
CommandName="DeleteSurveyObject"><i class="glyphicon glyphicon-trash"></i> </asp:LinkButton> <br />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
我也能刪除,也做服務器編碼deletion.But當只有一個第二路段記錄,不能夠在刪除時顯示列表視圖。
protected void OnPagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
(lvOrderInstall.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
this.GetAllOrderInstall();
TabName.Value = "installation";
}
protected void lvSurvey_ItemCommand(object source, ListViewCommandEventArgs e)
{
if(e.CommandName == "DeleteObject")
{
string[] param = e.CommandArgument.ToString().Split('|');
hfInstallID.Value = param[0].ToString();
DELETEINSTALL(int.Parse(hfInstallID.Value), clsCommon.gConstDTOMode_Delete, clsCommon.gConstActive_Status);
GetAllOrderInstall();
TabName.Value = "installation";
litMsg.Text = "Record deleted successfully";
}
}
綁定代碼隱藏你的列表視圖中'如果(!的IsPostBack)' – Valkyrie
它不工作,我已經給這個代碼 – aniltc
u能指https://www.aspsnippets.com/Articles/ Display-Show-data-in-ListView-from-database-in-ASPNet-using-C-and-VBNet.aspx這個鏈接 –