我在 GridView 行中有一个更新面板。我已按照所有标准程序从后面的代码更新面板,但似乎没有任何效果..
<asp:UpdatePanel ID="UpdatePanelBoost" runat="server" RenderMode="Inline" UpdateMode="Conditional">
<ContentTemplate >
<asp:LinkButton ID="LinkButtonBoost"
runat="server" Font-Size="XX-Small" Text="Boost Up"
OnCommand="LinkButtonBoost_Command"></asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButtonBoost" EventName="Command"/>
</Triggers>
</asp:UpdatePanel>
代码绑定
protected void LinkButtonBoost_Command(object sender, CommandEventArgs e)
{
HiddenField HiddenFieldId = (HiddenField)GridView2.Rows[0].FindControl("HiddenFieldId");
LinkButton Boostupbutton= (LinkButton)sender;
int SId= Convert.ToInt32(HiddenFieldSubjectId.Value);
int QId =Convert.ToInt32(GridView2.DataKeys[0].Value.ToString ());
UpdatePanel UpdatePanelBoost = (UpdatePanel)GridView2.Rows[0].FindControl("UpdatePanelBoost");
if (e.CommandName == "Boost Up")
{
QuestionDataAccess.InsertQuestionBoost(QId, new Guid(Membership.GetUser().ProviderUserKey.ToString()), SId);
Boostupbutton.CommandName = "Boost Down";
Boostupbutton.CommandArgument = "Boost Down";
UpdatePanelBoost.Update();
}
if(e.CommandName=="Boost Down")
{
if (QuestionDataAccess.RemoveQuestionBoost(new Guid(Membership.GetUser().ProviderUserKey.ToString()), QId))
{
Boostupbutton.CommandArgument = "Boost Up";
Boostupbutton.CommandName = "Boost Up";
UpdatePanelBoost.Update();
}
}
}