void GridChanged(object sender, System.EventArgs e)
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.
DataGrid1.DataBind();
}
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.
DataGrid1.DataBind();
}
void GridChanged(object sender, System.EventArgs e)
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex;
this.DataGrid1.DataSource=....; // Rebind the data.
DataGrid1.DataBind();
}
编译器错误信息: CS0117: “System.EventArgs”并不包含对“NewPageIndex”的定义源错误: 行 34:
行 35: // Set CurrentPageIndex to the page the user clicked.
行 36: DataGrid1.CurrentPageIndex = e.NewPageIndex;
行 37:
行 38: // Rebind the data
请继续讨论。
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataSource = products.Getguestview(Session["code"].ToString());
DataGrid1.DataBind();
}
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex;
this.DataGrid1.DataSource=....; // Rebind the data.
DataGrid1.DataBind();
}
<script runat="server">
jlzx.equipDB products = new jlzx.equipDB();
void Page_Load(Object sender, EventArgs e) {
if(!IsPostBack)
{
// Databind and display the list of favorite product items
if(Session["kind"].ToString()=="guest")
{
DataGrid1.DataSource = products.Getguestview(Session["code"].ToString());
DataGrid1.DataBind();
}
else if(Session["kind"].ToString()=="user")
{
DataGrid1.DataSource = products.Getuserview(Session["code"].ToString());
DataGrid1.DataBind();
}
else
{
DataGrid1.DataSource = products.Getadminview();
DataGrid1.DataBind();
}
}
}
void GridChanged(Object sender, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex;
// Rebind the data.
if(Session["kind"].ToString()=="guest")
{
DataGrid1.DataSource = products.Getguestview(Session["code"].ToString());
DataGrid1.DataBind();
}
else if(Session["kind"].ToString()=="user")
{
DataGrid1.DataSource = products.Getuserview(Session["code"].ToString());
DataGrid1.DataBind();
}
else
{
DataGrid1.DataSource = products.Getadminview();
DataGrid1.DataBind();
}
}</script>
{
// Set CurrentPageIndex to the page the user clicked.
DataGrid1.CurrentPageIndex = e.NewPageIndex; jlzx.equipDB products = new jlzx.equipDB();
// Rebind the data.
if(Session["kind"].ToString()=="guest")
{
DataGrid1.DataSource = products.Getguestview(Session["code"].ToString());
DataGrid1.DataBind();
}
else if(Session["kind"].ToString()=="user")
{
DataGrid1.DataSource = products.Getuserview(Session["code"].ToString());
DataGrid1.DataBind();
}
else
{
DataGrid1.DataSource = products.Getadminview();
DataGrid1.DataBind();
}
}
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace jlzx {
public class equipDB : System.Web.UI.UserControl{ public DataView Getguestview(string code)
{ // Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["admin"]);
SqlCommand myCommand = new SqlCommand("dt_retrunguest", myConnection); // Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@code",SqlDbType.Char,2);
param.Value = code;
myCommand.Parameters.Add( param );
// Execute the command
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = myCommand;
if (myConnection.State==ConnectionState.Closed)
myConnection.Open();
DataSet ds=new DataSet();
sda.Fill(ds,"tb1");
myConnection.Close();
DataView result = ds.Tables["tb1"].DefaultView; // Return the dataview result
return result;
}
你少個"d"啊
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
你只試一下,如果還是不能,沒辦法!!
都是这句代码惹得祸,我删除掉它后就一切正常,有水能告诉我它的确切含义?学习中。等待。
重载页面时都重载数据绑定,然后在分页绑定,也就是说把第一个if,else去掉。