datagrid edit textbox

Posted on 2005-04-07
Medium Priority
Last Modified: 2010-04-07
using asp.net (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
  • 2
LVL 43

Accepted Solution

TimCottee earned 500 total points
ID: 13727227
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 43

Expert Comment

ID: 13727235

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.


Author Comment

ID: 13727312
i always wondered what that property was for :)

thanks tim.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

809 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