Stuart
Stuart

Reputation: 699

How to Set Edit Mode for Specific Column & Row in a Gridview ASP .Net

I know that GridView1.EditIndex = e.NewEditIndex will set the whole row in edit mode but what I wanted is that I can set the specific Column in a Row. Please take the below example:

TITLE ---- DESCRIPTION ---- QUANTITY

Row1

Row2

Row3

I want to set QUANTITY of Row2 to be in edit mode. How can I do that? Is it possible?

Upvotes: 0

Views: 1629

Answers (2)

Jumpei
Jumpei

Reputation: 621

 <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

You can set the specific column readonly like above.

Upvotes: 1

Related Questions