put in DataGrid1_PageIndexChanged event:DataGrid1.CurrentPageIndex = e.NewPageIndex 'Re-binddata
gshope(北京.Net) ,“如果你的DataSet是页面类的一个字段那就不用再生成了”什么意思,不懂我的代码是这样: dim MyConnection as SqlConnectionsub page_load(sender as object,e as eventargs) MyConnection=new SqlConnection("server=nirvana;database=mpc;uid=sa;pwd=sa;") if not IsPostBack BindListCompany(DropDownListCompany) BindListType(DropDownListType) end if end subSub ButtonSearch_Click(sender As Object, e As EventArgs) dim MyCommand as new sqlDataAdapter("cpxx_search",MyConnection) MyCommand.SelectCommand.Commandtype=Commandtype.storedprocedure MyCommand.SelectCommand.Parameters.add(new sqlParameter("@Companyid",sqlDbType.int)) MyCommand.SelectCommand.Parameters("@Companyid").value=DropDownListCompany.SelectedIndex MyCommand.SelectCommand.Parameters.add(new sqlParameter("@cptypeid",sqlDbType.int)) MyCommand.SelectCommand.Parameters("@cptypeid").value=DropDownListType.SelectedIndex MyCommand.SelectCommand.Parameters.add(new sqlParameter("@cpmc",sqlDbType.Varchar)) MyCommand.SelectCommand.Parameters("@cpmc").value=Trim(TextboxName1.value) dim ds as new dataset() Mycommand.fill(ds,"result") DataGrid1.DataSource=ds.tables("result").defaultView DataGrid1.DataBind()End Sub 应该怎么写DataGrid1_PageIndexChanged 事件? 谢谢
private sub DataGrid1_PageIndexChanged(object source, system.Web.UI.WebControls.DataGridPageChangedEventArgs e) DataGrid1.CurrentPageIndex=e.NewPageIndex DataGrid1.DataSource=ds.tables("result").defaultView DataGrid1.DataBind() end sub
'Re-binddata
dim MyConnection as SqlConnectionsub page_load(sender as object,e as eventargs) MyConnection=new SqlConnection("server=nirvana;database=mpc;uid=sa;pwd=sa;")
if not IsPostBack
BindListCompany(DropDownListCompany)
BindListType(DropDownListType)
end if
end subSub ButtonSearch_Click(sender As Object, e As EventArgs) dim MyCommand as new sqlDataAdapter("cpxx_search",MyConnection)
MyCommand.SelectCommand.Commandtype=Commandtype.storedprocedure
MyCommand.SelectCommand.Parameters.add(new sqlParameter("@Companyid",sqlDbType.int))
MyCommand.SelectCommand.Parameters("@Companyid").value=DropDownListCompany.SelectedIndex
MyCommand.SelectCommand.Parameters.add(new sqlParameter("@cptypeid",sqlDbType.int))
MyCommand.SelectCommand.Parameters("@cptypeid").value=DropDownListType.SelectedIndex
MyCommand.SelectCommand.Parameters.add(new sqlParameter("@cpmc",sqlDbType.Varchar))
MyCommand.SelectCommand.Parameters("@cpmc").value=Trim(TextboxName1.value) dim ds as new dataset()
Mycommand.fill(ds,"result") DataGrid1.DataSource=ds.tables("result").defaultView
DataGrid1.DataBind()End Sub
应该怎么写DataGrid1_PageIndexChanged 事件?
谢谢
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
Binding();
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}
DataGrid1.CurrentPageIndex=e.NewPageIndex
DataGrid1.DataSource=ds.tables("result").defaultView
DataGrid1.DataBind()
end sub