Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have an update panel with a gridview. The gridview consists of a button column. I want everytime this button is clicked, the update panel should be refreshed. From what i have been able to achieve, the buttton works fine but i would only be able to see the effect when i refreshed the whole page again. I need to see the effect on the click event without refreshing the page. How do i make this gridview button cause partial postback

What I have tried:

ASP.NET
<pre lang="ASP.NET"><asp:TemplateField HeaderText="Action" Visible="True">
                               <ItemTemplate>
                                   <asp:Button Visible='<%# string.IsNullOrEmpty(Eval("Signout_Time").ToString()) %>' ID="out" runat="server" Text="Sign out" CommandName="SignOut"  CommandArgument='<%#Eval("SN") %>' ClientIDMode="AutoID"/>
                               </ItemTemplate>
                           </asp:TemplateField>


This is the code behind.

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
               Button lb = e.Row.FindControl("out") as Button;
               ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);
           }
    }


this is what the button does when i click
C#
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
       {
          if (e.CommandName == "SignOut")
           {
               string sN = e.CommandArgument.ToString();
               reg.sn = int.Parse(sN);
           string sign = System.DateTime.Now.ToString("yyyy-MM-dd:HH:mm:ss"); // get time out time
           reg.signout = sign;
           reg.SignOut(); // Save the signout time in db



After the whole process, i want the button to update only the updatepanel.
Posted
Updated 12-Oct-16 7:51am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900