Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to edit from grid and bind all the details in the form.. while editing grid shows textbox in each columns.
How to avoid it?

What I have tried:

<asp:GridView ID="ProjectGrid" runat="server" AllowPaging="true" AutoGenerateColumns="false" PageSize="10"
                                      CssClass="table table-bordered table-vcenter" ShowHeaderWhenEmpty="true" HeaderStyle-HorizontalAlign="Center" AlternatingRowStyle-BackColor="DimGray">
                                      <HeaderStyle BackColor="#FF9800" ForeColor="white" CssClass="headerRow" />
                                      <AlternatingRowStyle BackColor="white" />
                                      <Columns>
                                          <asp:BoundField HeaderText="User Name" DataField="UserName" ControlStyle-BorderColor="Transparent" ItemStyle-Width="7%" ItemStyle-ForeColor="#0c28c3" />
                                          <asp:BoundField HeaderText="Date" DataField="Date" DataFormatString="{0:dd/MM/yyyy}" ControlStyle-BorderColor="Transparent" ItemStyle-Width="5%" />
                                          <asp:BoundField HeaderText="Project Name" DataField="ProjectName" ControlStyle-BorderColor="Transparent" ItemStyle-Width="15%" />
                                          <asp:BoundField HeaderText="Task Assigned" DataField="TaskName" ControlStyle-BorderColor="Transparent" ItemStyle-Width="25%" />
                                          <asp:BoundField HeaderText="Status" DataField="status" ControlStyle-BorderColor="Transparent" ItemStyle-Width="7%" NullDisplayText="Status Not Entered" />
                                          <asp:BoundField HeaderText="Hours" DataField="hour" ControlStyle-BorderColor="Transparent" ItemStyle-Width="3%" />
                                          <asp:TemplateField ItemStyle-Width="8%">
                                              <ItemTemplate>
                                                  <asp:LinkButton ID="btnEdit" runat="server" CommandName="Edit" Text="Edit" Style="color: white"
                                                      CommandArgument='<%#Eval("EmpID")%>' BackColor="#00bcd4" CssClass="btn btn-primary"></asp:LinkButton>
                                                  <asp:HiddenField ID="hdndate" runat="server" Value='<%#Container.DataItem("date")%>' />
                                                  <asp:LinkButton ID="btnDelete" runat="server" CommandName="Delete" Text="Delete" Style="color: white" CommandArgument='<%#Eval("EmpID")%>'
                                                      OnClientClick="return confirm('Are you sure to Delete?')" BackColor="#c53c6b" CssClass="btn btn-primary"></asp:LinkButton>
                                                  <asp:HiddenField ID="hdnID" runat="server" Value='<%#Eval("TaskID")%>' />
                                              </ItemTemplate>
                                          </asp:TemplateField>
                                      </Columns>
                                      <RowStyle CssClass="grdRow" />
                                  </asp:GridView>
Posted
Comments
Richard Deeming 11-Apr-17 13:28pm    
Are you saying you only want to be able to edit certain columns? If so, set the ReadOnly property to True on the BoundField for each column you don't want to edit.
Member 13040174 12-Apr-17 6:35am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900