asp.net 中gridview每页显示8条数据怎么做?就改一下pagesize就行了吗?我改了怎么不行啊?
前台代码:<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"CellPadding=...
前台代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="Both">
<Columns>
<asp:BoundField DataField="Anumber" HeaderText="员工编号" ReadOnly="True" />
<asp:BoundField DataField="employeename" HeaderText="员工姓名" />
<asp:BoundField DataField="date" HeaderText="日期" />
<asp:BoundField DataField="worktime" HeaderText="正班工时" />
<asp:BoundField DataField="overtime" HeaderText="加班工时" />
<asp:BoundField DataField="absentwork" HeaderText="矿工天数" />
<asp:BoundField DataField="late" HeaderText="迟到分钟" />
<asp:BoundField DataField="askleave" HeaderText="请假天数" />
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
.cs中的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["manageConnectionString"].ConnectionString);
con.Open();
string sqlstr3 = "select name from sysobjects where xtype='U ' and name<>'sysdiagrams' and name<>'manager' order by name";
SqlDataAdapter myada3 = new SqlDataAdapter(sqlstr3, con);
DataSet myds3 = new DataSet();
myada3.Fill(myds3);
DropDownList1.DataSource = myds3.Tables[0];
DropDownList1.DataValueField = "name";
DropDownList1.DataBind();
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["manageConnectionString"].ConnectionString);
con.Open();
string sqlstr4 = "select * from " + DropDownList1.SelectedValue;
SqlDataAdapter myada4 = new SqlDataAdapter(sqlstr4, con);
DataSet myds4 = new DataSet();
myada4.Fill(myds4);
this.GridView1.DataSource = null;
this.GridView1.DataSource = myds4.Tables[0];
this.GridView1.DataBind();
} 展开
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="Both">
<Columns>
<asp:BoundField DataField="Anumber" HeaderText="员工编号" ReadOnly="True" />
<asp:BoundField DataField="employeename" HeaderText="员工姓名" />
<asp:BoundField DataField="date" HeaderText="日期" />
<asp:BoundField DataField="worktime" HeaderText="正班工时" />
<asp:BoundField DataField="overtime" HeaderText="加班工时" />
<asp:BoundField DataField="absentwork" HeaderText="矿工天数" />
<asp:BoundField DataField="late" HeaderText="迟到分钟" />
<asp:BoundField DataField="askleave" HeaderText="请假天数" />
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
.cs中的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["manageConnectionString"].ConnectionString);
con.Open();
string sqlstr3 = "select name from sysobjects where xtype='U ' and name<>'sysdiagrams' and name<>'manager' order by name";
SqlDataAdapter myada3 = new SqlDataAdapter(sqlstr3, con);
DataSet myds3 = new DataSet();
myada3.Fill(myds3);
DropDownList1.DataSource = myds3.Tables[0];
DropDownList1.DataValueField = "name";
DropDownList1.DataBind();
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["manageConnectionString"].ConnectionString);
con.Open();
string sqlstr4 = "select * from " + DropDownList1.SelectedValue;
SqlDataAdapter myada4 = new SqlDataAdapter(sqlstr4, con);
DataSet myds4 = new DataSet();
myada4.Fill(myds4);
this.GridView1.DataSource = null;
this.GridView1.DataSource = myds4.Tables[0];
this.GridView1.DataBind();
} 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询