Results 1 to 2 of 2

Thread: page index changed datagrid problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    182

    page index changed datagrid problem

    I have the following code and when i click on page number..it shows nothing..it shows data for the first time but on the second time it doesnt.

    Also i believe that the pageindexchanged is not getting called. howver if i remove (!PageIspostback) it works fine.

    can somebody plz help me in this coz it has taken a lot of my time and i would appreciate any help.

    public partial class ThmbListing : System.Web.UI.UserControl
    {

    #region Fields ------------------------------------------------------------------------

    public DataSet ds = new DataSet();
    public DataTable myPropertyTable = new DataTable();
    public Icon icon;

    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    MyDataBind();
    }

    }

    public void MyDataBind()
    {

    this.icon = new Icon();
    SqlConnection cn = new SqlConnection();
    cn.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["DBConnectionString"];
    SqlDataAdapter da = new SqlDataAdapter("select * from ResidentialListingView", cn);
    da.Fill(ds);
    DataGrid1.DataSource = ds;
    DataGrid1.DataBind();
    cn.Close();


    }

    protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
    {

    ViewState["CurrentPage"] = e.NewPageIndex;
    DataGrid1.CurrentPageIndex = e.NewPageIndex;
    MyDataBind();
    }

    }

    }
    }

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: page index changed datagrid problem

    Is it because everytime you click the link it's actually a postback?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width