マスターページを使用しているときにページングが機能しない理由がわかりません。マスターページにリンクされていない別のファイルに同じコードを配置すると、魅力的に機能します。しかし、それをマスターページにリンクすると機能しません。
これが私のマークアップです
<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=" " OnClick="Edit" CommandArgument='<%# Eval("addressID")%>'
CssClass="editButton" runat="server">
</asp:LinkButton>
<asp:LinkButton Text=" " 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>
これが私のコードビハインドです。
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);
}
}
}
私を助けてください。どんな助けでも大歓迎です。