c# - How can I make gridview cells be textboxes instead of labels? -


my gridview supposed display data excel datasheet. able display data in grid labels excel values. i'm trying make editable gridview , hence keep in in edit mode why need cells textboxes. how can that?

visual explanation

<asp:gridview id="gridview4" runat="server" cellpadding="4" forecolor="#333333"              gridlines="none" onrowcommand="gridview4_rowcommand"              onselectedindexchanged="gridview4_selectedindexchanged">             <alternatingrowstyle backcolor="white" />             <columns>                 <asp:templatefield showheader="false">                     <itemtemplate>                         <asp:linkbutton onclick="updaterow_click"                              id="linkbutton1"                              runat="server"                              causesvalidation="false"                              commandname="update"                              text="update">                         </asp:linkbutton>                     </itemtemplate>                 </asp:templatefield>              </columns>             <footerstyle backcolor="#990000" font-bold="true" forecolor="white" />             <headerstyle backcolor="#990000" font-bold="true" forecolor="white" />             <pagerstyle backcolor="#ffcc66" forecolor="#333333" horizontalalign="center" />             <rowstyle backcolor="#fffbd6" forecolor="#333333" />             <selectedrowstyle backcolor="#ffcc66" font-bold="true" forecolor="navy" />             <sortedascendingcellstyle backcolor="#fdf5ac" />             <sortedascendingheaderstyle backcolor="#4d0000" />             <sorteddescendingcellstyle backcolor="#fcf6c0" />             <sorteddescendingheaderstyle backcolor="#820000" />         </asp:gridview> 

add more itemtemplate textboxes in it, set textboxes value columns name. , dont forget set autogeneratecolumns false.

        <columns>             <asp:templatefield showheader="false">                 <itemtemplate>                     <asp:linkbutton onclick="updaterow_click"                          id="linkbutton1"                          runat="server"                          causesvalidation="false"                          commandname="update"                          text="update">                     </asp:linkbutton>                 </itemtemplate>            </asp:templatefield>            <asp:templatefield>                 <itemtemplate>                     <asp:textbox                          id="textbox1"                          runat="server"                          text='<%#eval("column1")>'>                     </asp:textbox>                 </itemtemplate>            </asp:templatefield>            <asp:templatefield>                 <itemtemplate>                     <asp:textbox                          id="textbox2"                          runat="server"                          text='<%#eval("column2")%>'>                     </asp:textbox>                 </itemtemplate>            </asp:templatefield>            <asp:templatefield>                 <itemtemplate>                     <asp:textbox                          id="textbox3"                          runat="server"                          text='<%#eval("column3")%>'>                     </asp:textbox>                 </itemtemplate>             </asp:templatefield>          </columns> 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -