AllowCustomPaging

Discussion in 'ASP .Net Datagrid Control' started by Anthony Lombardo, Sep 25, 2003.

  1. Please help!

    I am trying to create a custom paging datagrid without success. I
    have set the VirtualItemCount(Actual Number of records),
    AllowPaging(true), AllowCustomPaging(true), and
    OnPageIndexChanged(changePage function). All have been set
    successfully, the changePage function is public in a C# codebehind
    page. Everything works fine on the page except when I have
    AllowCustomPaging = true, I get a javascript error stating...Error:
    Expected Identifier when I first load the page, then when I try to
    click on one of the numerical page indexes, it gives me a second
    javscript error:
    Object expected. I have bound the datagrid to a dataset because of
    all the negativity I've seen on binding it to a DataReader. The first
    page of data all displays fine too. Does it matter that I have
    templated columns in the datagrid?

    Here's the HTML:

    <asp:DataGrid id="dgClaims" runat="server"
    AllowPaging="True"
    AllowCustomPaging="True"
    PageSize="10"
    PagerStyle-Mode="NumericPages"
    PagerStyle-PageButtonCount="10"
    PagerStyle-HorizontalAlign="Center"
    OnPageIndexChanged="changePage"
    BorderWidth="1"
    CellPadding="3"
    HeaderStyle-Font-Bold="True"
    AlternatingItemStyle-BackColor="Gainsboro"
    AutoGenerateColumns="False">
    <Columns>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="center"
    ItemStyle-HorizontalAlign="Center" DataField="dtetimestamp"
    HeaderStyle-Width="1" HeaderText="Date<br/>Entered" ReadOnly="True"
    DataFormatString="{0:d}" runat="server"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Claim<br>Number">
    <ItemTemplate>
    <a href='<%# "/carriers/claim.aspx?id=" +
    DataBinder.Eval(Container.DataItem, "claimID") + "&cl=1"%>'
    id="claimref" runat="server">
    <asp:Label Text='<%# DataBinder.Eval(Container.DataItem,
    "claimnumber")%>' ID="claim" runat="server">
    </asp:Label></a>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Appraiser">
    <ItemTemplate>
    <div align="center"><a href="javascript:winpopup('<%#
    "/carriers/app_profile.aspx?id=" + DataBinder.Eval(Container.DataItem,
    "appraiserID")%>');">
    <asp:Label Text='<%# DataBinder.Eval(Container.DataItem,
    "companyshortname")%>' ID="Label1" runat="server">
    </asp:Label></a></div>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Insured" >
    <ItemTemplate>
    <asp:Label Text='<%# DataBinder.Eval(Container.DataItem, "ifname") + "
    " + DataBinder.Eval(Container.DataItem, "ilname")%>' ID="insured"
    runat="server"/>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Claimant" >
    <ItemTemplate>
    <asp:Label Text='<%# DataBinder.Eval(Container.DataItem, "cfname") + "
    " + DataBinder.Eval(Container.DataItem, "clname")%>' ID="claimant"
    runat="server"/>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Vehicle" >
    <ItemTemplate>
    <asp:Label Text='<%# DataBinder.Eval(Container.DataItem,
    "vehicleyear") + " " + DataBinder.Eval(Container.DataItem,
    "vehiclemake") + " " + DataBinder.Eval(Container.DataItem,
    "vehiclemodel")%>' ID="vehicle" runat="server"/>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="Center"
    ItemStyle-HorizontalAlign="Center" DataField="dateofloss"
    HeaderText="Date of<br>Loss" ReadOnly="True" DataFormatString="{0:d}"
    runat="server"></asp:BoundColumn>
    <asp:BoundColumn HeaderStyle-HorizontalAlign="Center"
    ItemStyle-HorizontalAlign="Center" DataField="description"
    HeaderText="Status" ReadOnly="True" runat="server"></asp:BoundColumn>
    </Columns>
    </asp:DataGrid>


    Here's the C# code I have:

    private void Page_Load(object sender, System.EventArgs e)
    {
    SetupGrid(0);
    }

    public void changePage(object sender, DataGridPageChangedEventArgs e)
    {
    dgClaims.CurrentPageIndex = e.NewPageIndex;
    int intStart = dgClaims.CurrentPageIndex * dgClaims.PageSize;
    SetupGrid(intStart);
    }

    private void SetGrid(int startID)
    {
    string strSelect = "SELECT TOP " + dgClaims.PageSize + " claimID,..."
    SqlConnection strConnect=null;
    DataSet ds=null;
    SqlDataAdapter da=null;
    try
    {
    strConnect = new SqlConnection(ConfigurationSettings.AppSettings["DSN"]);
    ds = new DataSet();
    da = new SqlDataAdapter(strSelect, strConnect);
    da.Fill(ds, "claims");
    dgClaims.VirtualItemCount = GetCount(status);// EQUALS 13
    dgClaims.DataSource = ds.Tables["claims"].DefaultView;
    dgClaims.DataBind();
    }
    catch
    {
    if (Session["cID"]==null)
    {
    Response.Redirect("/carriers/default.aspx?msg=1");
    }
    }
    finally
    {
    if (strConnect!=null)
    strConnect.Close();
    if (ds!=null)
    ds.Dispose();
    }
    }




    ANY HELP is appreciated!

    Thanks,

    Anthony, Lintech Systems
     
    Anthony Lombardo, Sep 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Litvack

    DataGrid Issue: "Cannot compute Count" for AllowCustomPaging

    Steve Litvack, Aug 12, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    174
    Steve Litvack
    Aug 16, 2003
Loading...

Share This Page