Hi
in gridview who is fetching the records i allowpaging "true" ,but next page of gridview is not showing data. What is wrong with my code? Please advice.
here is the code:
<asp:GridView ID="GridView1" AllowPaging="true" runat="server"
onpageindexchanging="GridView1_PageIndexChanging" >
</asp:GridView>
C#
public partial class SearchAll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindEmployee();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
BindEmployee();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
public void BindEmployee() {
string constr = ConfigurationManager.ConnectionStrings["CompanyInfoEventsConnectionString"].ConnectionString;
using (SqlConnection conn = new SqlConnection(constr))
{
string sqlQuery = @"select [FullName]
,[Position]
,[Cellar]
,[GeocellCellar]
,[Extention]
,[Email]
from GpiEmployees where (FullName like '%' + @search +'%')
or (Position like '%' + @search + '%')
or (Cellar like '%' + @search + '%')
or (GeocellCellar like '%' + @search +'%')
or (Extention like '%' + @search + '%')
or (Email like '%' + @search +'%')";
using (SqlCommand cmd = new SqlCommand(sqlQuery, conn))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
cmd.Parameters.AddWithValue("@search", TextBox1.Text.Trim());
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
}
}