How do I enable editing for a single column in Gridview?

advertisements

Right now, I have three columns in a GridView:

<asp:GridView ID="ProjectTable" runat="server" AutoGenerateColumns="False" DataSourceID="PopulateProjectTable">
        <Columns>
            <asp:BoundField DataField="ProjectID" HeaderText="Project ID" SortExpression="ProjectID" />
            <asp:BoundField DataField="ProjectDescription" HeaderText="Project Description" SortExpression="ProjectDescription" />
            <asp:BoundField DataField="ProjectNotes" HeaderText="Project Notes" SortExpression="ProjectNotes" />
        </Columns>
</asp:GridView>
<asp:SqlDataSource ID="PopulateProjectTable" runat="server" ConnectionString="<%$ ConnectionStrings:sandboxConnectionString %>" SelectCommand="SELECT * FROM [Projects]"></asp:SqlDataSource>

For the most part, it's read only except for the third column. At first, I thought about using AutoGenerateEditButton, but it causes every column to be writable. I thought that would be fine, but I don't want to give user that much power. Therefore, I thought of two ways to tackle this problem. The first way was to have it such that the third column would be readable by default, but by left clicking a row in that column, it would change it to be writable. It would be reminiscent of lightly double clicking a file name in Windows and it would be editable.

The second way is to disable the editing for the first two columns when I hit the AutoGenerateEditButton and to instead only have it "work" for the third column. However, I'm unsure of how to do this part.

Is my first way even possible in GridView? Note that I am doing all of this in Visual Studio. Thank you.


Go to the design mode for the .aspx file.

Click on your GridView control.

Click the small ">" arrow button that appears.

Click Edit Columns.

In the selected fields list, you can set the attributes for each column.

Make a column editable by setting readOnly to false.