DataSet ds =.............;
GridView1.DataSource = ds;
GridView1.AllowPaging = true;
GridView1.DataBind();
但是点击gridview上的数字页时就出错.
把它连接到数据库控件很容易,但我不想用这种方法,请高手教教我吧。
[此贴子已经被作者于2006-9-11 17:51:53编辑过]
[此贴子已经被作者于2006-9-11 17:51:53编辑过]
[此贴子已经被作者于2006-9-12 9:33:06编辑过]
我得怎么还不行呀,点击两下下一页才有反应,这是怎么回事呀?
源码如下:
public partial class admin_jsjl : System.Web.UI.Page
{
protected oradb conn = new oradb();
protected DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
// if (!Page.IsPostBack)
// {
string sql = "select * from sjjl ";
conn.open();
// SqlConnection myConnection = new SqlConnection("Data Source=XIAOHUA;Initial Catalog=HRIS;User ID=sa");
OracleDataAdapter myCommand = new OracleDataAdapter(sql, conn.dbconn);
myCommand.Fill(ds, "SJJL");
this.GridView1.AllowPaging = true;
this.GridView1.DataSource = ds;
this.GridView1.DataBind();
// }
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
Response.Write(e.NewPageIndex);
if (e.NewPageIndex!=-1)
{
this.GridView1.PageIndex = e.NewPageIndex;
// rolesArray = Roles.GetAllRoles();
this.GridView1.DataSource = ds; //string[]
// GridView1.DataBind();
//this.GridView1.DataBind();
// DataBind();
}
}
}