【问题标题】:DataGridView column with textbox , plus & minus button sign for Quantity带有文本框的 DataGridView 列,数量的加号和减号按钮
【发布时间】:2016-01-26 13:00:14
【问题描述】:

我在 ASP.Net (Framework 4.0) 中做这个项目。

我已将 gridview 与数据库绑定。我已经编辑了 gridview 并添加了一个模板字段并在项目模板中添加 2 个按钮 (+ & -) 以及来自工具箱的文本框。

我的问题是,在btnPlusbtnMinus 点击文本框中的数量会增加或减少,但我找不到 textbox1.text 来显示值。

我应该如何将文本框中的数量与标签中的价格相乘?

有什么问题,我应该尝试什么其他方法.....?

【问题讨论】:

    标签: asp.net sql-server gridview datagridview


    【解决方案1】:

    其实我自己解决的。 如果有人想使用此代码,请通过它。

    在网格视图中为 btnPlus 和 btnMinus 使用 ButtonField,而不是使用 TemplateField。

    为 GridView1 选择 GridView_RowCommand 并将 CommandName 赋予 ButtonField 以用于两者。

    代码如下

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
     {
       if (e.CommandName == "btnPlus")
       {
          // Your Logic for Adding & Multiplication
       }
       if (e.CommandName == "btnMinus")
       {
          // Your Logic for Subtraction & Multiplication
       }
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      • 2021-12-16
      • 1970-01-01
      相关资源
      最近更新 更多