ti posto parte del codice:
questo è quello che faccio per cambiare la pagina
codice:
public void Change_Page(object sender, DataGridPageChangedEventArgs e)
{
// display a new page of data
DataGrid1.EditItemIndex = -1;
DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindGrid();
}
mentre il codice del mio pulsante è questo:
codice:
Panel3.Visible=false;
Session["cerca"]=true;
Session["ricerca"]=txRicerca.Text;
BindGrid();
codice per compilare il datagrid (BindGrid):
codice:
string query;
if ((bool)Session["cerca"]==true)
{
string ricerca=Session["ricerca"].ToString();
ricerca="%"+ricerca+"%";
query="select * from Ana, Cla where Ana.AnaClaId=Cla.ClaOwnId and (AnaLnm like '" + ricerca +"' or AnaDes like '"+ ricerca+"') order by AnaCod";
}
else if((Session["filtro"].ToString()!="")&(Session["filtro"].ToString()!="Tutte"))
{
query="Select * from Ana,Cla where AnaClaId=ClaOwnId and ClaOwnId="+Convert.ToInt32(Session["filtro"])+" order by AnaCod";
}
else
{
query="select * from Ana, Cla where Ana.AnaClaId=Cla.ClaOwnId order by ClaDes, AnaCod";
}
SqlDataAdapter myCommand = new SqlDataAdapter(query, conn);
DataSet ds = new DataSet();
if(myCommand.Fill(ds, "Ana")==0)
{
lbl_Mess.Text="Nessuna anagrafiche trovata";
lbl_Mess.Visible=true;
DataGrid1.Visible=false;
}
else
{
DataGrid1.DataSource=ds.Tables["Ana"].DefaultView;
DataGrid1.DataBind();
lbl_Mess.Visible=false;
DataGrid1.Visible=true;
}
Grazie mille per qualsiasi suggerimento
ste