datagrid edit textbox

Posted on 2005-04-07
Last Modified: 2010-04-07
using (vb), i have a datagrid that allows editing.

i'm wondering why when i click on the edit button, all fields change to textboxes and not just the ones i've made an EditItemTemplate column for.

any suggestions how i'd prevent all of them becoming editable?


sub dgProject_Edit(sender As Object, e As DataGridCommandEventArgs)
      dgProject.EditItemIndex = CInt(E.Item.ItemIndex)
      Call DisplayProjectDatagrid(Nothing, Nothing)
end sub



                  <asp:BoundColumn DataField="fldProjectID" Visible="False"/>
                  <asp:TemplateColumn HeaderText="Project Thumbnail" HeaderStyle-Width="150">
                  <asp:ImageButton CausesValidation=False
                        ImageUrl='<%# Container.DataItem("fldProjectThumbnail")%>'
                  <asp:BoundColumn DataField="fldProjectName"  HeaderStyle-Width="180" HeaderText="Project Name" Visible="true"/>
                  <asp:TemplateColumn HeaderText="Project Description" HeaderStyle-Width="300">
                              <asp:Label ID="lblOriginalProjectDescription" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "fldProjectDescription") %>' />
                              <asp:TextBox id="txtNewProjectDescription" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "fldProjectDescription") %>'/>
                  <asp:ButtonColumn Text="Delete" HeaderStyle-Width="50" CommandName="Delete" />
                  <asp:editcommandcolumn Edittext="Edit" canceltext="Cancel" updatetext="Update" HeaderStyle-Width="100" />

            <AlternatingItemStyle BackColor=#d8e4f8 />


thanks all.
Question by:vbnewbie01
    LVL 44

    Accepted Solution

    Hi vbnewbie01,

                   <asp:BoundColumn DataField="fldProjectName"  HeaderStyle-Width="180" HeaderText="Project Name" Visible="true" ReadOnly="true"/>

    Add the ReadOnly attribute to the column definition.

    This will stop it.

    Tim Cottee
    LVL 44

    Expert Comment


    Of course there is also a checkbox to set this at design time if you are using the datagrid property builder to create your columns.

    LVL 1

    Author Comment

    i always wondered what that property was for :)

    thanks tim.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now