Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid paging is not working in web user control

Status
Not open for further replies.

malathireddyb

Programmer
Feb 3, 2004
3
IN
Im using a web user control to display the list of members based on some conditions.The code works well and good but problem is that the datagrid pagination is not working Its not showing any compile time or runtime error but in the browsers status bar showing "object required " when ever page is postbacked

 
did you call the paging sub in your html?

OnPageIndexChanged="ChangePage"

then in your code behind

Sub ChangePage(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs)

Datagrid.CurrentPageIndex = e.NewPageIndex
BindYourGrid()

End Sub

 
yes I have added the onpageindexchanged event Im attaching the code pls view it


private void Page_Load(object sender, System.EventArgs e)
{

if(!Page.IsPostBack)
{
bindgrid();
}
}

private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex=e.NewPageIndex;
bindgrid();
}
public void bindgrid()
{
SqlConnection connectionObject=new SqlConnection(connectionString);
SqlDataAdapter DataAdapterObject=new SqlDataAdapter("select * from table",connectionObject);
DataSet ds=new DataSet();
DataAdapterObject.Fill(ds,"table");
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
}


Im getting javascript error as object required in the browser
Thanks for the reply


 
Are you using the right sub? Is there a pageindexchanging sub? Not sure I'm using VS2005 now and that's how we're doing it.
Code:
Protected Sub gvResults_PageIndexChanging(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvResults.PageIndexChanging

        Try
            gvResults.PageIndex = e.NewPageIndex

            gvResults.DataSource = Cache.Get("DataSetForGridView")
            gvResults.DataBind()
        Catch ex As Exception
            Response.Redirect(LogErrorsAndGetRedirectionString(ex), False)
        End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top