Dear All,
I created one web page and that page in i writed code like below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Gridpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadData();
BindGridView();
}
}
private void LoadData()
{
string constr = "Data Source=.;Database=abcClassifieds;user id=sa;password=123;";
string query = "SELECT ID, ContactPhoto, Title, Description, Price, City, DateAdded FROM productDetailsTable where categories='education'";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void BindGridView()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["abcConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand();
SqlDataReader sdr = null;
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
switch (DropDownList1.SelectedValue)
{
case "High To Low":
cmd.CommandText = "Select * From productDetailsTable where categories='education' order by price desc";
break;
case "Low To High":
cmd.CommandText = "select * from productDetailsTable where categories='education' order by price asc";
break;
case "Recently Ads":
cmd.CommandText = "select * from productDetailsTable where categories='education' order by id desc";
break;
default:
break;
}
try
{
sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
finally
{
GridView1.DataSource = sdr;
GridView1.DataBind();
if (!sdr.IsClosed)
{
sdr.Dispose();
sdr.Close();
}
con.Close();
con.Dispose();
}
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
BindGridView();
}
}
here got a small error like :The data source does not support server-side data paging.
how resolve this problem please reply me