title: prevent button inside a gridview to postback using javascript
body: <p>i have gridview that uses template and i have two buttons inside the template. Here is my code for gridview:</p>
  
  <pre><code>      &lt;asp:GridView ID="gvtransaction" runat="server" AutoGenerateColumns="False" Width="60%"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField HeaderText=""&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblid" runat="server" Text='&lt;%# Bind("id") %&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Consumer"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblfirstname" runat="server" Text='&lt;%# Bind("FirstName") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Name"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lbllastname" runat="server" Text='&lt;%# Bind("LastName") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Amount"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblamount" runat="server" Text='&lt;%# Bind("Amount") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText=""&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblcurrencyID" runat="server" Text='&lt;%# Bind("CurrencyID") %&gt;' Visible="false"&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Account Name"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblcurrencyname" runat="server" Text='&lt;%# Bind("CurrencyName") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Status"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lblstatus" runat="server" Text='&lt;%# Bind("Status") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="DateCreated"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Label ID="lbldatecreated" runat="server" Text='&lt;%# Bind("DateCreated") %&gt;'&gt;&lt;/asp:Label&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
  
                  &lt;asp:TemplateField HeaderText=""&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Button ID="btnApprove" runat="server" Text="Approve" CommandName="Select" OnClick="btnApprove_Click" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText=""&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:Button ID="btnReject" runat="server" Text="Reject" CommandName="Select" OnClick="btnReject_Click" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>now what i want to happen is to prevent the button (if clicked twice ) to postback. If the user clicks the button for the second time, it shouldn't post back when it sees that the status field of the row is not equal to pending. How can i do this using jquery.? I have no idea on how to code this. Some articles that i've read suggests that i should use AJAX (i dont know how to code AJAX)...
  please help..</p>