UpdatePanel未更新

时间:2013-03-23 08:11:40

标签: asp.net visual-studio-2008 updatepanel

我在GridView Row中有一个更新面板。我已经按照所有标准程序从后面的代码更新面板,但似乎没有任何工作..

               <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>

Codebhind

    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();
        }
    }

}

1 个答案:

答案 0 :(得分:0)

将您的gridview放在UpdatePanel内。

当网格的任何行更新时,页面将不会回发。

按照此更新面板使用&gt;&gt;

http://msdn.microsoft.com/en-us/library/bb399001%28v=vs.100%29.aspx