|
-
Aug 25th, 2006, 12:30 AM
#1
Thread Starter
Addicted Member
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();
}
}
}
}
-
Aug 25th, 2006, 09:23 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|