?
Solved

datagrid edit textbox

Posted on 2005-04-07
3
Medium Priority
?
245 Views
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:DataGrid
                  id=dgProject  
                  OnItemDataBound="dgProject_ItemDataBound"
                  OnUpdateCommand="dgProject_Update"
                  OnCancelCommand="dgProject_Cancel"
                  OnEditCommand="dgProject_Edit"
                  OnDeleteCommand="dgProject_Delete"
                  DataKeyField="fldProjectID"
                  HeaderStyle-BackColor="#000000"
                  HeaderStyle-Font-Bold="True"
                  HeaderStyle-ForeColor="#ffffff"
                  runat="server"
                  BorderWidth="0"
                  ShowFooter="True"
                  Width="100%"
                  AutoGenerateColumns="False">
            
            <Columns>

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

            <AlternatingItemStyle BackColor=#d8e4f8 />

            </asp:DataGrid>



thanks all.
0
Comment
Question by:vbnewbie01
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
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
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13727235
vbnewbie01,

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.

Tim
0
 
LVL 1

Author Comment

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

thanks tim.
0

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