谁能告诉我如何在gridview中为按钮编码 [英] can anyone tell me how can i code for the button in the gridview

查看:87
本文介绍了谁能告诉我如何在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

推荐答案

为gridview中的每个按钮添加CommandName并

使用grdCardWallet_RowCommand进行所需的操作.

Add CommandName for each button in the gridview and

use grdCardWallet_RowCommand to do your operation as required.

<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中为按钮编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆