0

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

}

4

1 回答 1

0

把你的gridview放在里面UpdatePanel

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

按照此更新面板使用>>

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

于 2013-03-23T08:39:30.220 回答