62,272
社区成员
发帖
与我相关
我的任务
分享
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ListView runat="server" ID="LimingchStudio_ListView" DataKeyNames="ItemID"
InsertItemPosition="LastItem" DataSourceID="ObjectDataSource1"
>
<LayoutTemplate>
<table id="Table2" runat="server" style=" border:solid thick blue;">
<tr runat="server" id="itemPlaceholder"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td ><input name="Item" type="checkbox" value='<%# Eval("ItemID")%>'/></td>
<td><%# Eval("Title").ToString().Length>16?Eval("Title").ToString().Substring(0,5)+"......":Eval("Title")%></td>
<td><%#Eval("Begin")%></td><td><%#Eval("Deadline") %></td>
<td><%#Eval("Originalprice") %></td><td ><%#Eval("Currentprice") %></td><td><%#Eval("Supplier")%></td>
<td><%#Eval("Address")%></td></tr>
<tr><td colspan="3" style=" border-bottom-width:medium; border-bottom-style:ridge"></td>
<asp:Button ID="btnEdit" Text="编辑" runat="server" CommandName="Edit"></asp:Button>
<asp:Button ID="btnDelete" Text="删除" runat="server" CommandName="Delete" OnClientClick="return confirm('您确认要删除此条数据信息吗?')"></asp:Button>
</tr>
</ItemTemplate>
<EditItemTemplate>
<td><input name="Item" type="checkbox" value='<%# Eval("ItemID")%>'/></td>
<td><%# Eval("Title").ToString().Length>16?Eval("Title").ToString().Substring(0,5)+"......":Eval("Title")%></td>
<td><%#Eval("Begin")%></td><td><%#Eval("Deadline") %></td>
<td><%#Eval("Originalprice") %></td><td ><%#Eval("Currentprice") %></td><td><%#Eval("Supplier")%></td>
<td><%#Eval("Address")%></td></tr>
<tr ><td colspan="3" style=" border-bottom-width:medium; border-bottom-style:ridge;">
<asp:LinkButton runat="server" ID="btnIpdate" Text="更新" CommandName="Update"></asp:LinkButton>
<asp:LinkButton runat="server" Text="取消" CommandName="Cancel"></asp:LinkButton></td></tr>
</EditItemTemplate>
<InsertItemTemplate>
<td><input name="Item" type="checkbox" value='<%# Eval("ItemID")%>'/></td>
<td><%# Eval("Title").ToString().Length>16?Eval("Title").ToString().Substring(0,5)+"......":Eval("Title")%></td>
<td><%#Eval("Begin")%></td><td><%#Eval("Deadline") %></td>
<td><%#Eval("Originalprice") %></td><td ><%#Eval("Currentprice") %></td><td><%#Eval("Supplier")%></td>
<td><%#Eval("Address")%></td></tr>
</InsertItemTemplate>
</asp:ListView>
<asp:LinqDataSource ID="LinqDataSource_LimingchStudio" runat="server" ContextTypeName="chtNortwindDataContext"
TableName="iyaobao" EnableDelete="true" EnableInsert="true" EnableUpdate="true"></asp:LinqDataSource>
<asp:DataPager runat="server" ID="DataPager1" PageSize="6" PagedControlID="LimingchStudio_ListView">
<Fields>
<asp:TemplatePagerField>
<PagerTemplate>
<hr />
<b>
页码
<asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.TotalRowCount>0 ?(Container.StartRowIndex / Container.PageSize)
+1 : 0 %>" /> / <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Math.Ceiling(System.Convert.ToDouble(Container.TotalRowCount) / Container.PageSize) %>" />
( <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.TotalRowCount %>" />条数据)
<br />
</b>
</PagerTemplate>
</asp:TemplatePagerField>
<asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="true" ShowPreviousPageButton="true"
ShowNextPageButton="true" ShowLastPageButton="true" FirstPageText="第一页" PreviousPageText="上一页"
NextPageText="下一页" LastPageText="最后一页"/>
</Fields>
</asp:DataPager>
<br />
<asp:Label ID="lblMessage" runat="server" Text="" Font-Italic="true" ForeColor="#FF3300"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
//错误提示
protected void LimingchStudio_ListView_ItemDeleted(object sender,ListViewDeletedEventArgs e)
{
if (e.Exception != null)
{
e.ExceptionHandled = true;
this.lblMessage.Text = "数据无法删除,错误提示如下:" + Environment.NewLine + e.Exception.Message;
}
else
{
this.lblMessage.Text = "信息删除成功";
}
}
protected void LimingchStudio_ListView_ItemInserted(object sender,ListViewInsertedEventArgs e)
{
if (e.Exception != null)
{
e.ExceptionHandled = true;
this.lblMessage.Text = "数据无法添加,错误信息如下:" + Environment.NewLine + e.Exception.Message;
}
else
{
this.lblMessage.Text = "信息添加成功";
}
}
}
//总页数
int pageAll = 0;
//总记录数
int countAll = 0;
//加载事件
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["page"] = 1;
GetCount(1);
}
}
//绑定控件
private void GetCount(int pageIndex)
{
CountAll();
this.lblCount.Text = "共有 " + countAll + " 条记录 | 当前 " + pageIndex + "/" + pageAll + " 页";
this.GridView1.DataSource = LoginLogManager.FindAll(pageIndex);
this.GridView1.DataBind();
}
//计算总页数
private void CountAll()
{
countAll = LoginLogManager.CountALL();
if (countAll % 10 == 0)
{
pageAll = countAll / 10;
}
else
{
pageAll = (countAll / 10) + 1;
}
}
//首页
protected void imgFrist_Click(object sender, ImageClickEventArgs e)
{
GetCount(1);
Index = 1;
}
//上页
protected void imgPre_Click(object sender, ImageClickEventArgs e)
{
if (Index >1)
{
Index--;
GetCount(Index);
}
else
{
GetCount(1);
}
}
//下一页
protected void imgNext_Click(object sender, ImageClickEventArgs e)
{
CountAll();
if (Index < pageAll)
{
Index++;
GetCount(Index);
}
else
{
GetCount(pageAll);
}
}
//末页
protected void imgEnd_Click(object sender, ImageClickEventArgs e)
{
CountAll();
GetCount(pageAll);
Index = pageAll;
}
private int index;
public int Index
{
get { return (int)ViewState["page"]; }
set { ViewState["page"] = value; }
}