本文介绍了谁能告诉我如何在gridview中为按钮编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请给我举个例子...

我有两个按钮批准"和拒绝".在单击这些按钮上....我想相应地更改数据库中的值....

Thankyou

please provide me one example...

i have two buttons "Approve" and "Reject". on clicking on these buttons .... i want to change the value in the database accordingly....

thankyou

推荐答案

<asp:TemplateField ItemStyle-VerticalAlign="Middle">
                              <ItemTemplate>
                                  <asp:LinkButton ID="lnkApprove"

                                      Text="Approve" CommandArgument='<%# Eval("Approve") %>' CommandName="Arrpove"

                                       runat="server"></asp:LinkButton>
                                  <div class="ht4">
                                  </div>
                                  <asp:LinkButton ID="lnkReject" CommandName="Reject" CommandArgument='<%# Eval("Reject") %>'

                                      Text="Reject"  runat="server"></asp:LinkButton>
                              </ItemTemplate>
                          </asp:TemplateField>




使用下面的代码进行操作




use the below codebehind for your action

protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
   {

           if (e.CommandName == "Aprove")
           {

           }
           if (e.CommandName == "reject")
           {

           }
       }


这篇关于谁能告诉我如何在gridview中为按钮编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 19:51