Question

I dont know why paging is not working when i use master page. If I put the same code in another file which in not linked with master page it works like a charm. But when I link it to master page it doesn't work.

here is my mark up

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<div id="menu_content">
    <div class="tabs">
        My Addresses</div>
    <div class="midContent">
        <asp:GridView ID="addressGrd" OnPageIndexChanging="addressGrd_PageIndexChanging"
            Width="816px" ForeColor="#ffffff" AllowSorting="true" HeaderStyle-BackColor="#222222"
            HeaderStyle-Height="60px" runat="server" AutoGenerateColumns="False" GridLines="None"
            AllowPaging="True" PagerSettings-FirstPageText="First" PagerSettings-LastPageText="Last"
            PagerSettings-Mode="NextPreviousFirstLast" PageSize="5" PagerSettings-PageButtonCount="4">
            <Columns>
                <asp:BoundField DataField="customerName" HeaderText="Name" ReadOnly="True" />
                <asp:BoundField DataField="customerCompany" HeaderText="Company" ReadOnly="True" />
                <asp:BoundField DataField="customerPhone" HeaderText="Phone" ReadOnly="True" />
                <asp:BoundField DataField="addressLine1" HeaderText="Address 1" ReadOnly="True" />
                <asp:BoundField DataField="addressLine2" HeaderText="Address 2" ReadOnly="True" />
                <asp:BoundField DataField="city" HeaderText="City" ReadOnly="True" />
                <asp:BoundField DataField="state" HeaderText="State" ReadOnly="True" />
                <asp:BoundField DataField="zipCode" HeaderText="Zip Code" ReadOnly="True" />
                  <asp:TemplateField>
                  <HeaderTemplate>
                                Main Address
                            </HeaderTemplate>
                            <ItemTemplate>                                    
                                <asp:ImageButton runat="server" OnClick="changeStatus" ID="imgStatus" CommandArgument='<%#Eval("mainAddress")+","+ Eval("addressID")%>'
                                    ImageUrl='<%# Bind_Image(Eval("mainAddress").ToString()) %>' />
                            </ItemTemplate>
                        </asp:TemplateField>                           
                        <asp:TemplateField>
                            <HeaderTemplate>
                                Action
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="editItem" Text="&nbsp; &nbsp; &nbsp;" OnClick="Edit" CommandArgument='<%# Eval("addressID")%>'
                                    CssClass="editButton" runat="server">                                       
                                </asp:LinkButton>
                                <asp:LinkButton Text="&nbsp; &nbsp; &nbsp;" ID="deleteItem" CssClass="deleteButton"
                                    runat="server" CommandArgument='<%# Eval("addressID")%>' OnClientClick="return confirm('Do You Want To Delete ?')"
                                    OnClick="Delete">                                        
                                </asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
            </Columns>


            <PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First"
                LastPageText="Last" />
            <PagerStyle BackColor="#222222" Height="30px" VerticalAlign="Bottom" HorizontalAlign="Center" />
            <RowStyle Height="50px" BackColor="#117186" />
            <AlternatingRowStyle BackColor="#0b4d5b" />
        </asp:GridView>
        <a href="AddAddresses.php5" style="text-decoration:none"><div style="float:right; margin-bottom:20px; margin-right:20px"><input type="button" class="buttonEffect" value="Register New Address" /></div></a>
    </div>
</div>

and here is my code behind.

retrievedata3ct rd3ct;
DataTable dt;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
    rd3ct = new retrievedata3ct();
       dt = new DataTable();
       ds = new DataSet();


    if (!this.IsPostBack)
    {
        addAddresses();
    }

}

public void addAddresses()
{
    rd3ct = new retrievedata3ct();
    ds = new DataSet();
    ds = rd3ct.addressesSelection("", "");

    addressGrd.DataSource = ds.Tables[0];
    addressGrd.DataBind();
    addressGrd.Visible = true;

    //ScriptManager.GetCurrent(this).RegisterPostBackControl(addressGrd);
}

public string Bind_Image(string Status)
{
    bool status = Convert.ToBoolean(Status);

    if (status)
    {
        return "adminCP/resources/images/icons/tick_circle.png";
    }
    else
    {
        return "adminCP/resources/images/icons/cross_circle.png";
    }
}

protected void addressGrd_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    addressGrd.PageIndex = e.NewPageIndex;
    addAddresses();
}

protected void Delete(object sender, EventArgs e)
{

    LinkButton lnkRemove = (LinkButton)sender;
    string ds = "";
    ds = rd3ct.addressesDeletion(lnkRemove.CommandArgument);

    if (ds == "OK")
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Record Deleted.');", true);
        addAddresses();
    }
    else
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Error Occurred.');", true);
    }
}


protected void Edit(object sender, EventArgs e)
{

    LinkButton lnkRemove = (LinkButton)sender;
    Session["addressID"] = "";
    Session["addressID"] = lnkRemove.CommandArgument;

    Response.Redirect("editAddresses.php5", false);
}   

protected void changeStatus(object sender, EventArgs e)
{
    string ds = "";
    ImageButton ib = (ImageButton)sender;

    string[] commandArgs = ib.CommandArgument.ToString().Split(new char[] { ',' });
    string status = commandArgs[0];
    string id = commandArgs[1];

    if (status == "True")
    {
        ds = rd3ct.addressesStatusUpdate(id, "False");
        if (ds == "OK")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Status Disabled.');", true);
            addAddresses();
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Error Occurred.');", true);
        }
    }
    else
    {
        ds = rd3ct.addressesStatusUpdate(id, "True");
        if (ds == "OK")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Status Enabled.');", true);
            addAddresses();
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Error Occurred.');", true);
        }
    }



}   

Please help me out. Any help would be highly appreciated.

No correct solution

OTHER TIPS

Have you tried to create an empty master page to put the content into? I suspect your master page is breaking the GridView.

Problem Solved.

Actually button name was conflicting in grid view.

I was having a button and its ID was 'submit' and in my another page there was also a button named with the same ID. thats why gridview paging was not working.

R.I.P Coding.. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top