也可以联系我QQ 414522115
或者发我邮箱 [email protected]
或者发我邮箱 [email protected]
解决方案 »
- 关于activereport 2032的错!!!!!!
- 同一页面读取好几种不同分类的数据,应该采取什么方法比较适宜
- ghostXP sp3 安装了IIS5.1后却不能浏览网站,请问正确的部署步骤和解决方法
- 关于this.Button1.Attributes.Add的问题,和别的不太一样哦!来看一下吧
- datalist中进行动态添加控件
- 关于DropDownLIst的问题
- 怎么让textedit 控件只能输入数字!
- 数据在当页提交判断提交成功的代码应该写?
- 高手請看看!
- asp 转到 asp.net 用c#调用原有的组件,现在遇到了捆难,不会用啊,请各位帮帮忙啊
- 用的微软的AJAX框架发现的问题
- if (Session["count"] != null) System.NullReferenceException: 未将对象引用设置到对象的实例。
苦笑
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
GridView gv=e.Item.FindControl("GridView1") as GridView;
//这里做你想做的事情.......
}
} <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ItemTemplate>
</asp:Repeater>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:GridView runat="server">
</asp:GridView>
<ItemTemplate>
</asp:Repeater>
还有其他好的分页控件吗
<HeaderTemplate>
<table class="ptbl" cellpadding="0" cellspacing="1">
<tr>
<th width="20px"></th>
<th width="30%">性别</th>
<th width="30%">人数</th>
<th>百分比</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="cursor:pointer" onclick="expend(this,this.innerText)">+</td>
<td><%# Convert.ToInt32(Eval("Sex"))==0?"男":"女" %></td>
<td><%# Eval("Peosons")%></td>
<td><%# Eval("percent")%></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<asp:GridView ID="RptChld" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="Sex">
<ItemTemplate>
<%# Convert.ToInt32(Eval("Sex"))==0?"男":"女" %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Age" HeaderText="Age" />
<asp:BoundField DataField="Address" HeaderText="Address" />
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>public partial class b : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.RptParent.DataSource = this.GroupSource;
this.RptParent.DataBind();
} } /// <summary>
/// 汇总
/// </summary>
private DataTable GroupSource
{
get
{
DataTable dt = new DataTable();
dt.Columns.Add("Sex", typeof(int));
dt.Columns.Add("Peosons", typeof(int));
dt.Columns.Add("percent", typeof(string));
dt.Rows.Add(0, 2, "40%");
dt.Rows.Add(1, 3, "60%");
return dt;
}
} /// <summary>
/// 明细
/// </summary>
private DataTable DTLSource
{
get
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Sex", typeof(int));
dt.Columns.Add("Age", typeof(int));
dt.Columns.Add("Address", typeof(string)); dt.Rows.Add("A1", 0, 28, "上海");
dt.Rows.Add("A2", 0, 22, "江苏");
dt.Rows.Add("B1", 1, 21, "浙江");
dt.Rows.Add("B2", 1, 22, "山东");
dt.Rows.Add("B3", 1, 27, "广州");
return dt;
}
} protected void RptParent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
GridView chld = e.Item.FindControl("RptChld") as GridView;
if (chld != null)
{
int sex = (int)((DataRowView)e.Item.DataItem)["Sex"];
DataView dv = new DataView(this.DTLSource);
dv.Sort = "Sex";
dv.RowFilter = "Sex=" + sex.ToString();
chld.DataSource = dv;
chld.DataBind();
} }
}}
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class _Default : System.Web.UI.Page
{
private string ConnString = ConfigurationManager.ConnectionStrings["NorthwindConString"].ToString();
private PagedDataSource ps;
private int pagination;
private int maxPageCount;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["pagination"] != null)
{
pagination = Convert.ToInt32(Request.QueryString["pagination"].ToString());
}
if (!IsPostBack)
{
ps = new PagedDataSource();
SetBind();
}
}
private void SetBind()
{
using (SqlConnection con = new SqlConnection(ConnString))
{
SqlDataAdapter da = new SqlDataAdapter("select * from Products", con);
DataSet ds = new DataSet();
da.Fill(ds);
ps = new PagedDataSource();
//实例的数据源,你自己按实际更改
ps.DataSource = ds.Tables[0].DefaultView;
//这个很重要,就是设定为允许分页
ps.AllowPaging = true;
//每页显示的个数
ps.PageSize = 5;
//显示第几页,从0开始
ps.CurrentPageIndex = pagination;
//绑定数据
dl_EmployeesList.DataSource = ps;
dl_EmployeesList.DataBind();
maxPageCount = ps.PageCount;
}
}
protected void btn_backPaging_Click(object sender, EventArgs e)
{
if (pagination > 0)
{
pagination--;
Response.Redirect("Default.aspx?pagination=" + pagination);
}
}
protected void btn_nextPaging_Click(object sender, EventArgs e)
{
SetBind();
if ( maxPageCount-1> pagination)
{
pagination++;
Response.Redirect("Default.aspx?pagination=" + pagination);
}
}
protected void btn_Paging_Click(object sender, EventArgs e)
{
}
}<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="dl_EmployeesList" runat="server" CellPadding="3" RepeatColumns="1">
<ItemTemplate>
<table style="font-size:9pt; font-family:Verdana">
<tr align="center">
<td style="width: 270px">
<asp:Label ID="lb_EmployeeId" runat="server" Text='<%# Eval("ProductId") %>' />
</td>
</tr>
<tr align="center">
<td style="width: 270px">
<asp:Label ID="lb_FirstName" runat="server" Text='<%# Eval("ProductName") %>' />
</td>
</tr>
<tr align="center">
<td style="width: 270px">
<asp:Label ID="lb_LastName" runat="server" Text='<%# Eval("UnitPrice") %>' />
</td>
</tr>
</table>
</ItemTemplate>
<HeaderTemplate>
</HeaderTemplate>
<FooterTemplate>
</FooterTemplate>
<HeaderStyle HorizontalAlign="Left" />
<FooterStyle HorizontalAlign="Right" />
<ItemStyle BackColor="#F0F0F0" />
<AlternatingItemStyle BackColor="#E0E0E0" />
</asp:DataList>
<br />
<asp:Button ID="btn_backPaging" runat="server" Text="上一页" OnClick="btn_backPaging_Click"/>
<asp:Button ID="btn_nextPaging" runat="server" Text="下一页" OnClick="btn_nextPaging_Click"/>
</div>
</form>
</body>
</html>这个是datalist用aspnetpager分页,原理大同小异,数据用的northwind,2000自带的那个,你有的话,能跑起看效果