【问题标题】:Adding custom link buttons to ASP GridView向 ASP GridView 添加自定义链接按钮
【发布时间】:2017-12-09 14:26:14
【问题描述】:

我有以下 GridView,其中我在选择行的第一列中有一个选择按钮。

我想在名为"Compute" 的选择按钮旁边的新列中放置另一个类似的(自定义/用户定义的)按钮。我该怎么做?

<asp:GridView ID="GridViewSavingsTracker" AutoGenerateColumns="false" runat="server" OnRowCommand="GridViewSavingsTracker_RowCommand">
    <Columns>
        <asp:CommandField ShowSelectButton="true" />
        <asp:BoundField DataField="creditorName" HeaderText="Creditor Name" />
        <asp:BoundField DataField="amount" HeaderText="Principal Amount" />
        <asp:BoundField DataField="interestRate" HeaderText="Interest Rate" />   
    </Columns>
</asp:GridView>

【问题讨论】:

    标签: c# asp.net gridview


    【解决方案1】:
    <asp:ButtonField Text="Text_on_the_Button" CommandName="Command1" ButtonType="Link" />
    

    Command_Name = 获取或设置一个字符串,该字符串表示单击 ButtonField 对象中的按钮时要执行的操作。

    在服务器端:

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if(e.CommandName=="Command1")
        {
            // What you want to do when the button is clicked.
        }
    }
    

    来源:https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.buttonfield(v=vs.110).aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-21
      • 2011-06-09
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 2011-05-04
      • 2016-07-18
      相关资源
      最近更新 更多