Manoj Maharana

Manoj Maharana

  • NA
  • 362
  • 128.6k

Add add row in first row in gridview inline grid c#

Feb 17 2017 8:52 AM
How do i add first row of gridview as add row in inline gridview (asp .net). 
 
Here is the code:
 
  1. <asp:GridView ID="gvTaskDetails" runat="server" Width="100%" CssClass="table table-bordered"  
  2.                                                             AutoGenerateColumns="false" Font-Names="Arial"   
  3.                                                             HeaderStyle-BackColor="#e7f2ff" AllowPaging="true" ShowFooter="true"  
  4.                                                             OnPageIndexChanging="gvTaskDetails_PageIndexChanging" OnRowCommand="gvTaskDetails_RowCommand" OnRowEditing="gvTaskDetails_RowEditing"   
  5.                                                             OnRowUpdating="gvTaskDetails_RowUpdating" OnRowCancelingEdit="gvTaskDetails_RowCancelingEdit" DataKeyNames="ID" OnRowDataBound="gvTaskDetails_RowDataBound"  
  6.                                                             PageSize="10">  
  7.                                                             <Columns>  
  8.                                                                 <asp:TemplateField>  
  9.                                                                     <ItemTemplate>  
  10.                                                                         <asp:HiddenField ID="hdnID" runat="server" Value='<%#Eval("ID") %>' />  
  11.                                                                         <%--<asp:Label ID="lblCustomerID" runat="server"  
  12.                                                                             Text='<%# Eval("ID")%>'></asp:Label>--%>  
  13.                                                                     </ItemTemplate>  
  14.                                                                     <FooterTemplate>  
  15.                                                                         <%--<asp:TextBox ID="txtCustomerID" Width="40px"  
  16.                                                                                     MaxLength="5" runat="server"></asp:TextBox>--%>  
  17.                                                                     </FooterTemplate>  
  18.                                                                 </asp:TemplateField>  
  19.   
  20.                                                                   <asp:TemplateField HeaderText="Company Name">  
  21.                                                                     <ItemTemplate>  
  22.                                                                         <asp:Label ID="lblcmpnm" Text='<%#Eval("Companynm")%>' runat="server"> </asp:Label>  
  23.                                                                     </ItemTemplate>  
  24.                                                                     <EditItemTemplate>  
  25.   
  26.                                                                         <asp:TextBox ID="txtcmpnm" runat="server" CssClass="form-control"  
  27.                                                                             Text='<%#Eval("Companynm")%>'></asp:TextBox>  
  28.                                                                        <%--  <span id="erroreml1" runat="server" style="color:red"></span>--%>  
  29.                                                                     </EditItemTemplate>  
  30.                                                                     <FooterTemplate>  
  31.                                                                         <asp:TextBox ID="txtcmpnm" runat="server" CssClass="form-control" placeholder="Company Name"></asp:TextBox>  
  32.                                                                           <span id="errorcmpnm" runat="server" style="color:red"></span>  
  33.                                                                         <%--  <asp:RequiredFieldValidator ID="rfvPrice" ControlToValidate="txteml" runat="server"  
  34.                                                                             ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator>  
  35.                                                                         <asp:RegularExpressionValidator ID="regexEmailValid" runat="server" ForeColor="Red" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txteml" ErrorMessage="Invalid Email Format"></asp:RegularExpressionValidator>--%>  
  36.                                                                     </FooterTemplate>  
  37.                                                                 </asp:TemplateField>  
  38.   
  39.   
  40.                                                                 <asp:TemplateField HeaderText="Email">  
  41.                                                                     <ItemTemplate>  
  42.                                                                         <asp:Label ID="lblTname" Text='<%#Eval("Email")%>' runat="server"> </asp:Label>  
  43.                                                                     </ItemTemplate>  
  44.                                                                     <EditItemTemplate>  
  45.   
  46.                                                                         <asp:TextBox ID="txteml" runat="server" CssClass="form-control"  
  47.                                                                             Text='<%#Eval("Email")%>'></asp:TextBox>  
  48.                                                                          <span id="erroreml1" runat="server" style="color:red"></span>  
  49.                                                                     </EditItemTemplate>  
  50.                                                                     <FooterTemplate>  
  51.                                                                         <asp:TextBox ID="txteml" runat="server" CssClass="form-control" placeholder="Enter Email"></asp:TextBox>  
  52.                                                                           <span id="erroreml" runat="server" style="color:red"></span>  
  53.                                                                         <%--  <asp:RequiredFieldValidator ID="rfvPrice" ControlToValidate="txteml" runat="server"  
  54.                                                                             ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator>  
  55.                                                                         <asp:RegularExpressionValidator ID="regexEmailValid" runat="server" ForeColor="Red" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txteml" ErrorMessage="Invalid Email Format"></asp:RegularExpressionValidator>--%>  
  56.                                                                     </FooterTemplate>  
  57.                                                                 </asp:TemplateField>  
  58.   
  59.                                                                 <asp:TemplateField HeaderText="Phone">  
  60.                                                                     <ItemTemplate>  
  61.                                                                         <asp:Label ID="lblproject" Text='<%#Eval("Phone")%>' runat="server"> </asp:Label>  
  62.                                                                     </ItemTemplate>  
  63.                                                                     <EditItemTemplate>  
  64.                                                                         <asp:TextBox ID="txtph" TextMode="MultiLine" runat="server" CssClass="form-control"  
  65.                                                                             Text='<%#Eval("Phone")%>'></asp:TextBox>  
  66.                                                                         <span id="errorph1" runat="server" style="color:red"></span>  
  67.                                                                     </EditItemTemplate>  
  68.                                                                     <FooterTemplate>  
  69.                                                                         <asp:TextBox ID="txtph" TextMode="MultiLine" runat="server" CssClass="form-control" placeholder="Enter Phone Number"></asp:TextBox>  
  70.                                                                         <span id="errorph" runat="server" style="color:red"></span>  
  71.                                                                         <%--  <asp:RequiredFieldValidator ID="rfvPrices" ControlToValidate="txtph" runat="server"  
  72.                                                                             ErrorMessage="Required" ForeColor="Red"></asp:RequiredFieldValidator>--%>  
  73.                                                                     </FooterTemplate>  
  74.                                                                 </asp:TemplateField>  
  75.   
  76.                                                                 <asp:TemplateField HeaderText="Category">  
  77.                                                                     <ItemTemplate>  
  78.                                                                         <asp:Label ID="lblEmpName" Text='<%#Eval("Category")%>' runat="server"> </asp:Label>  
  79.                                                                     </ItemTemplate>  
  80.                                                                     <EditItemTemplate>  
  81.                                                                         <asp:TextBox ID="txtcat" runat="server" CssClass="form-control"  
  82.                                                                             Text='<%#Eval("Category")%>'></asp:TextBox>  
  83.                                                                     </EditItemTemplate>  
  84.                                                                     <FooterTemplate>  
  85.                                                                         <asp:TextBox ID="txtcat" CssClass="form-control" runat="server" placeholder="Enter Category"></asp:TextBox>  
  86.                                                                     </FooterTemplate>  
  87.                                                                 </asp:TemplateField>  
  88.   
  89.   
  90.   
  91.                                                                 <asp:TemplateField HeaderText="City">  
  92.                                                                     <ItemTemplate>  
  93.                                                                         <asp:Label ID="lblSdate" Text='<%#Eval("City")%>' runat="server"> </asp:Label>  
  94.                                                                     </ItemTemplate>  
  95.                                                                     <EditItemTemplate>  
  96.                                                                         <asp:TextBox ID="txtcity" runat="server" CssClass="form-control"  
  97.                                                                             Text='<%#Eval("City")%>'></asp:TextBox>  
  98.                                                                     </EditItemTemplate>  
  99.                                                                     <FooterTemplate>  
  100.                                                                         <asp:TextBox ID="txtcity" runat="server" CssClass="form-control" placeholder="Enter City"></asp:TextBox>  
  101.                                                                         
  102.                                                                     </FooterTemplate>  
  103.                                                                 </asp:TemplateField>  
  104.                                                                   <asp:TemplateField HeaderText="Comments">  
  105.                                                                     <ItemTemplate>  
  106.                                                                         <asp:Label ID="lblcmnts" Text='<%#Eval("Comments")%>' runat="server"> </asp:Label>  
  107.                                                                     </ItemTemplate>  
  108.                                                                     <EditItemTemplate>  
  109.                                                                         <asp:TextBox ID="txtcmnts"  TextMode="MultiLine" runat="server" CssClass="form-control"  
  110.                                                                             Text='<%#Eval("Comments")%>'></asp:TextBox>  
  111.                                                                     </EditItemTemplate>  
  112.                                                                     <FooterTemplate>  
  113.                                                                         <asp:TextBox ID="txtcmnts"  TextMode="MultiLine" runat="server" CssClass="form-control" placeholder="Enter Comments"></asp:TextBox>  
  114.                                                                         
  115.                                                                     </FooterTemplate>  
  116.                                                                 </asp:TemplateField>  
  117.   
  118.   
  119.                                                                 <asp:TemplateField HeaderText="Action">  
  120.                                                                     <ItemTemplate>  
  121.                                                                         <asp:LinkButton runat="server" Text="Edit" ID="imgEdit" CommandName="Edit" CommandArgument='<%#Eval("ID") %>'><img src="images/edit.png" alt="Edit" title="Edit Title" /> </asp:LinkButton>  
  122.                                                                         <asp:LinkButton ID="imgDelete" Text="Delete" runat="server" OnClientClick="return confirm('Are you sure to delete Task?');" CommandName="Delete" CommandArgument='<%#Eval("ID") %>'><img src="images/cross.png" alt="Edit" title="Delete Task" /></asp:LinkButton>  
  123.                                                                         <br />  
  124.                                                                         <asp:LinkButton ID="lnkopenpopup" runat="server" Text="Appointment" Style="float: left; margin-right: 5px;" CommandName="App" CommandArgument='<%#Eval("ID") %>' CssClass="label label-sm label-success"></asp:LinkButton>  
  125.                                                                     </ItemTemplate>  
  126.   
  127.                                                                     <EditItemTemplate>  
  128.                                                                         <asp:ImageButton ID="imgbtnUpdate" runat="server" CommandName="Update" ImageUrl="../Content/images/user_edit.png" ToolTip="Update" OnClientClick="return GetGridFooterRowvalues1()" />  
  129.                                                                         <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="images/cross.png" ToolTip="Cancel" />  
  130.                                                                     </EditItemTemplate>  
  131.   
  132.                                                                     <FooterTemplate>  
  133.                                                                         <asp:Button ID="btnsave" runat="server" Text="Add New" class="btn icon-btn btn-success btn-sm" OnClientClick="return GetGridFooterRowvalues()"  
  134.                                                                             OnClick="btnsave_Click" />  
  135.                                                                     </FooterTemplate>  
  136.                                                                 </asp:TemplateField>  
  137.                                                                 <%--  <asp:CommandField ShowEditButton="True" />--%>  
  138.                                                             </Columns>  
  139.                                                             <PagerStyle HorizontalAlign="Right" CssClass="paging-d" />  
  140.                                                             <AlternatingRowStyle CssClass="tr2" />  
  141.                                                             <%-- <AlternatingRowStyle BackColor="#C2D69B" />--%>  
  142.                                                         </asp:GridView>  
 

Answers (4)