Click here to Skip to main content
14,921,476 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I am new to asp.net ,I dont know how to trigger the add, edit,update controls to make them fire which is inside inside Gridview control

What I have tried:

ASP.NET
<pre><body>

<form id="form1" runat="server">

<div style="font-size:20px;font-family:Verdana">

Employee Details

<br />

</div>

<div align="center">

<asp:GridView ID="GridViewSample" runat="server" AutoGenerateColumns="False" Font-Names="Verdana"

AllowPaging="true" ShowFooter="true" PageSize="5" Width="75%" OnPageIndexChanging="GridViewSample_PageIndexChanging"

OnRowCancelingEdit="GridViewSample_RowCancelingEdit" OnRowEditing="GridViewSample_RowEditing"

OnRowUpdating="GridViewSample_RowUpdating" 

OnRowDeleting="GridViewSample_RowDeleting" OnRowCommand="GridViewSample_RowCommand"

BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" OnSelectedIndexChanged="GridViewSample_SelectedIndexChanged">

<AlternatingRowStyle BackColor="#FFD4BA" />

<FooterStyle BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" />

<PagerStyle BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" />

<HeaderStyle Height="30px" BackColor="#FF9E66" Font-Size="15px" BorderColor="#CCCCCC"

BorderStyle="Solid" BorderWidth="1px" />

<RowStyle Height="20px" Font-Size="13px" BorderColor="#CCCCCC" BorderStyle="Solid"

BorderWidth="1px" />

<Columns>

<asp:TemplateField HeaderText="EmpID" Visible="true">

<ItemTemplate>

<asp:Label ID="lblCustID" runat="server" Text='<%#Eval("CustID") %>'></asp:Label>

</ItemTemplate>

<FooterTemplate>

<asp:Label ID="lbladd" runat="server"></asp:Label>

</FooterTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Employee Name" HeaderStyle-Width="10%">

<ItemTemplate>

<asp:Label ID="lblEmpName" runat="server" Text='<%#Eval("EmpName") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtEmplName" runat="server" Text='<%#Eval("EmpName") %>'></asp:TextBox>

</EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddEmpName" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="reqName" ValidationGroup="validate" ControlToValidate="txtAddCustName" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>

</FooterTemplate>

<HeaderStyle Width="15%"></HeaderStyle>

</asp:TemplateField>

<asp:TemplateField HeaderText="Department" HeaderStyle-Width="15%">

<ItemTemplate>

<asp:Label ID="lblDept" runat="server" Text='<%#Eval("Dept") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtDept" runat="server" Text='<%#Eval("Dept") %>'></asp:TextBox>

</EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddDept" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="reqAdd1" ValidationGroup="validate" ControlToValidate="txtAddCustAdres1" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>

</FooterTemplate>

<HeaderStyle Width="15%"></HeaderStyle>

</asp:TemplateField>


<asp:TemplateField HeaderText="Salary" HeaderStyle-Width="10%">
<ItemTemplate>

<asp:Label ID="lblSalary" runat="server" Text='<%#Eval("Salary") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtSalary" runat="server" Text='<%#Eval("Salary") %>'></asp:TextBox>

</EditItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList ID="ddlSalary" runat="server" Text='<%#Eval("Salary") %>'></asp:DropDownList></>
    </EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddSalary" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="reqPhone" ValidationGroup="validate" ControlToValidate="txtAddCustPhone" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>

</FooterTemplate>

<HeaderStyle Width="10%"></HeaderStyle>

</asp:TemplateField>

<asp:TemplateField HeaderText="Age" HeaderStyle-Width="15%">

<ItemTemplate>

<asp:Label ID="lblAge" runat="server" Text='<%#Eval("Age") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtAge" runat="server" Text='<%#Eval("Age") %>'></asp:TextBox>

</EditItemTemplate>

<FooterTemplate>

<asp:TextBox ID="txtAddAge" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="reqEmail" ValidationGroup="validate" ControlToValidate="txtAddAge" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>

</FooterTemplate>

<HeaderStyle Width="15%"></HeaderStyle>

</asp:TemplateField>

<asp:TemplateField HeaderText="Edit/Delete" HeaderStyle-Width="15%">

<ItemTemplate>

<asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" />

<span onclick="return confirm('Are you sure want to delete?')">

<asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete" />

</span>

</ItemTemplate>

<EditItemTemplate>

<asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" />

<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />

</EditItemTemplate>

<FooterTemplate>

<asp:Button ID="btnInsertRecord" runat="server" Text="Add" ValidationGroup="ValgrpCust" CommandName="Insert" />

</FooterTemplate>

<HeaderStyle Width="15%"></HeaderStyle>

</asp:TemplateField>

</Columns>

</asp:GridView>

</div>

<%--<div><br />

<asp:Label ID="lblMessage" ForeColor="Green" Font-Bold="true" runat="server" Text=""></asp:Label>

</div>--%>

</form>

</body>

</html>
Posted
Updated 13-Feb-17 2:59am

1 solution

   
Comments
Karthik_Mahalingam 14-Feb-17 0:04am
   
5

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