Home All Groups Group Topic Archive Search About

search function on different page selected

Author
11 Mar 2005 9:38 PM
Esperanza
Hello .net expert !!
Here is my problem,

I made a litle function to do a search on a dataGrid
It works fine if I do the search while page 1 is selected.
Otherwise (if page 5 is selected example) I got the following error :

Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount


Thanks in advance !!
Esperanza

Here it goes :

//******************************************************
private void btnRecherche_Click(object sender, System.EventArgs e)
  {

   string strVar;
   string strSelection;
   strVar = this.txtRecherche.Text;

   strSelection = this.RadListSearch.SelectedItem.Text;

   try
   {
    if (strVar.Trim()!=null)
    {

     switch(strSelection)

     {
      //Recherche par nom
      case "Nom":
      this.dataViewGPPL.RowFilter = "XABALPH like '%" + strVar + "%'";
      break;

      //Recherche par no Téléphone
      case "No tel.":
      this.dataViewGPPL.RowFilter = "XTEL like '" + strVar + "'";
      break;

     }//fin du switch

     //faire le bind
     this.sqlCommandGPPL.Parameters["@GLNOTECH"].Value =
Session["Client_TECH_RDV"];
     this.sqlDataAdapGPPL.Fill(dataSet11);

     this.DataGrid1.DataSource = dataViewGPPL;
     this.DataGrid1.DataBind();

    }//fin du if


   }//fin du try


   catch (Exception ex)
   {
    throw ex;
   }


}

Author
15 Mar 2005 12:24 AM
Elton Wang
Hi Esperanza,

Do you know in which line the exception occurs? From your
code I can only see a button click event. I can't see any
thing related to CurrentPageIndex. Hope you can show more
info.

Elton Wang


Show quoteHide quote
>-----Original Message-----
>Hello .net expert !!
>Here is my problem,
>
>I made a litle function to do a search on a dataGrid
>It works fine if I do the search while page 1 is selected.
>Otherwise (if page 5 is selected example) I got the
following error :
>
>Invalid CurrentPageIndex value. It must be >= 0 and < the
PageCount
>
>
>Thanks in advance !!
>Esperanza
>
>Here it goes :
>
>//******************************************************
>private void btnRecherche_Click(object sender,
System.EventArgs e)
Show quoteHide quote
>  {
>
>   string strVar;
>   string strSelection;
>   strVar = this.txtRecherche.Text;
>
>   strSelection = this.RadListSearch.SelectedItem.Text;
>
>   try
>   {
>    if (strVar.Trim()!=null)
>    {
>
>     switch(strSelection)
>
>     {
>      //Recherche par nom
>      case "Nom":
>      this.dataViewGPPL.RowFilter = "XABALPH like '%" +
strVar + "%'";
>      break;
>
>      //Recherche par no Téléphone
>      case "No tel.":
>      this.dataViewGPPL.RowFilter = "XTEL like '" +
strVar + "'";
>      break;
>
>     }//fin du switch
>
>     //faire le bind
>     this.sqlCommandGPPL.Parameters["@GLNOTECH"].Value =
>Session["Client_TECH_RDV"];
>     this.sqlDataAdapGPPL.Fill(dataSet11);
>
>     this.DataGrid1.DataSource = dataViewGPPL;
>     this.DataGrid1.DataBind();
>
>    }//fin du if
>
>
>   }//fin du try
>
>
>   catch (Exception ex)
>   {
>    throw ex;
>   }
>
>
>}
>
>
>
>
>.
>