问题如下: datagrid 现在可以显示数据,也可以分页Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
Me.DataGrid1.DataBind()我在同一个页面中做了一个查询,也在同一个datagrid中显示数据,但是这个时候,查询就不能用了,请问这是怎么回事?请指教
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
Me.DataGrid1.DataBind()我在同一个页面中做了一个查询,也在同一个datagrid中显示数据,但是这个时候,查询就不能用了,请问这是怎么回事?请指教
当 AllowPaging 设置为真并且选定的数据源不实现 ICollection 时,AllowCustomPaging 必须为真,并且 ID 为 DataGrid1 的 DataGrid 必须设置 VirtualItemCount。
错误提示,这个提示看不懂
这些可以在属性生成器里设置的啊,我用过没遇上这样的问题。
if (!Page.IsPostBack)
{}
的问题把
服务器压力太大
没关系我们只是一个小网站,况且我还在学习当中,先用datagrid自动分页,以后再学高级的
http://anyqu.mblogger.cn/posts/6350.aspx
有详细的说明!
你的邦定语法怎么写的?
参考我的:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
BindData();
Response.Write(DateTime.Now.ToString("yyyy-MM-dd"));
}
}
private void BindData()
{
SqlConnection sqlcon = new SqlConnection(Configuration.ConnectionString);
SqlCommand sqlcom =new SqlCommand();
sqlcon.Open();
sqlcom.Connection = sqlcon;
sqlcom.CommandText = "select a.SubProjectID ,a.TSMainProID,FristCensorDate ,b.MainBulidUnit ,b.SubRegisterContent,"+
" c.sjdwmc,c.kcdwmc,b.SubProjectName " +
" from TS_ProState a left join TS_ProjectInformation b on a.SubProjectID = b.SubProjectID "+
" left join TS_TSProjectInfo c on a.SubProjectID = c.dxgcbh "+
" where a.SubProjectID like '%"+TextKeyWords.Text.ToString()+"%' and isnull(TSMainProID,'popopopo')!= 'popopopo'";
SqlDataReader my = null;
try
{
my = sqlcom.ExecuteReader();
projectinfo.DataSource = my;
projectinfo.DataBind();
}
catch(Exception e)
{
throw(e);
}
finally
{
sqlcon.Close();
my.Close();
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.projectinfo.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.projectinfo_ItemCommand);
this.projectinfo.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.projectinfo_ItemDataBound);
this.projectinfo.SelectedIndexChanged += new System.EventHandler(this.projectinfo_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
BindData(); }
注意那个TextKeyWords.Text.ToString()为你的关键字输入的textbox值!
private void projectinfo_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
try
{
projectinfo.CurrentPageIndex = e.NewPageIndex;
BindData();
}
catch
{ } }
Dim my As New OleDbDataAdapter("SELECT T_BookInfo.Book_ID where " & Me.DropDownList1.SelectedValue & " like '%" & Me.TextBox1.Text & "%' order by T_BookInfo.Book_ID desc", conn)
Dim ds As New DataSet
my.Fill(ds, "T_BookInfo") Me.DataGrid1.DataSource = ds.Tables("T_BookInfo").DefaultView
Me.DataGrid1.CurrentPageIndex = 0
Me.DataGrid1.DataKeyField = "Book_ID"
Me.DataGrid1.DataMember = "T_BookInfo"
Me.DataGrid1.DataBind()
分页
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
Me.DataGrid1.DataBind()
SELECT语句太长,我删除了一写,我对C#不懂,不过我还是看一下,你说的那个传,怎么传,我不会
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
//你的邦定函数
就可以了,我太不懂VB语法的!
blog.csdn.net/zhzuo/archive/2004/10/28/156647.aspx