Member 12605293 Ответов: 1

Как вызвать элементы управления внутри gridview


Привет я новичок в asp.net ,я не знаю, как вызвать элементы управления add, edit,update, чтобы заставить их срабатывать, которые находятся внутри элемента управления Gridview

Что я уже пробовал:

<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>

1 Ответов

Рейтинг:
0

Karthik_Mahalingam

5