【问题标题】:How to Set Edit Mode for Specific Column & Row in a Gridview ASP .Net如何在 Gridview ASP .Net 中为特定列和行设置编辑模式
【发布时间】:2013-12-15 05:36:43
【问题描述】:

我知道 GridView1.EditIndex = e.NewEditIndex 会将整行设置为编辑模式,但我想要的是我可以在行中设置特定的列。请看下面的例子:

TITLE ---- DESCRIPTION ---- QUANTITY

Row1

Row2

Row3

我想将 Row2 的 QUANTITY 设置为处于编辑模式。 我怎样才能做到这一点?有可能吗?

【问题讨论】:

  • 添加 readonly="true" 就可以了 :)

标签: asp.net gridview


【解决方案1】:
 <asp:gridview id="CustomersGridView" 
    datasourceid="CustomersSqlDataSource" 
    autogeneratecolumns="false"
    autogenerateeditbutton="true"
    allowpaging="true" 
    datakeynames="CustomerID"  
    runat="server">

    <columns>
      <asp:boundfield datafield="CustomerID"
        readonly="true"      
        headertext="Customer ID"/>
      <asp:boundfield datafield="CompanyName"
        convertemptystringtonull="true"
        headertext="Customer Name"/>
      <asp:boundfield datafield="Address"
        convertemptystringtonull="true"
        headertext="Address"/>
      <asp:boundfield datafield="City"
        convertemptystringtonull="true"
        headertext="City"/>
      <asp:boundfield datafield="PostalCode"
        convertemptystringtonull="true"
        headertext="ZIP Code"/>
      <asp:boundfield datafield="Country"
        convertemptystringtonull="true"
        headertext="Country"/>
    </columns>

  </asp:gridview>

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.readonly(v=vs.100).aspx

您可以像上面一样将特定列设置为只读。

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2013-12-26
    • 2012-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 2014-08-18
    • 2013-01-20
    • 1970-01-01
    相关资源
    最近更新 更多