Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
 
Here is my Source code for the previous quation,
 
Please make corrections if there any mistakes in the code.
 
<asp:GridView ID="GridView1" runat="server"  DataKeyNames="EmpNo"
            AllowPaging="true" AllowSorting="true" PageSize="5"
            onpageindexchanging="GridView1_PageIndexChanging"
            onrowcancelingedit="GridView1_RowCancelingEdit"
            onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
            onrowupdating="GridView1_RowUpdating"
            onselectedindexchanged="GridView1_SelectedIndexChanged"
            onsorting="GridView1_Sorting" EnableModelValidation="true"
            AutoGenerateColumns="false" onrowcommand="GridView1_RowCommand"
            ShowFooter="true" onrowdatabound="GridView1_RowDataBound">
            <RowStyle HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="White" />
            <EditRowStyle BackColor="#7C6F57" />
            <FooterStyle BackColor="#1C5E55" ForeColor="White" Font-Bold="True" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#E3EAEB" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
 
           <Columns>
<asp:TemplateField HeaderText="EmpNo" SortExpression="EmpNo" HeaderStyle-HorizontalAlign="Left"><EditItemTemplate>
<asp:TextBox ID="txtEmNo" runat="server" Text='<%#Eval("EmpNo") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmpNo" runat="server"/>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemNo" runat="server" Text='<%#Eval("EmpNo") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EmpName" SortExpression="EmpName" HeaderStyle-HorizontalAlign="Left">
<EditItemTemplate>
<asp:TextBox ID="txtEmpName" runat="server" Text='<%#Eval("EmpName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtEmpName" ValidationGroup="Add New"  ErrorMessage="Must Enter Emp Name"></asp:RequiredFieldValidator>
<span><asp:RegularExpressionValidator ID="RegExpValidator" runat="server" ControlToValidate="txtEmpName" ValidationGroup="Add New" ValidationExpression="^[A-Z a-z]+$" ErrorMessage="Only Charecters and white space are allowed">
</asp:RegularExpressionValidator></span>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmpName" runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtEmpName" ValidationGroup="Add New"  ErrorMessage="Must Enter Emp Name"></asp:RequiredFieldValidator>
<span><asp:RegularExpressionValidator ID="RegExpValidator" runat="server" ControlToValidate="txtEmpName" ValidationGroup="Add New" ValidationExpression="^[A-Z a-z]+$" ErrorMessage="Only Charecters and white space are allowed">
</asp:RegularExpressionValidator></span>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemName" runat="server" Text='<%#Eval("EmpName") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Designation" HeaderStyle-HorizontalAlign="Left" SortExpression="Designation">
<ItemTemplate><%# Eval("Designation") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropDesg" runat="server" SelectedValue='<%# Eval("Designation").ToString() %>'>
<asp:ListItem Selected="True">Select Designation</asp:ListItem>
<asp:ListItem Text="Manager" Value="Manager"></asp:ListItem>
<asp:ListItem Text="Asis Manager" Value="Asis Manager"></asp:ListItem>
<asp:ListItem Text="Sales Rep" Value="Sales Rep"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="dropDesg" runat="server">
<asp:ListItem Selected="True">Select Designation</asp:ListItem>
<asp:ListItem Text="Manager" Value="Manager"></asp:ListItem>
<asp:ListItem Text="Asis Manager" Value="Asis Manager"></asp:ListItem>
<asp:ListItem Text="Sales Rep" Value="Sales Rep"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
 
<%--<asp:TemplateField HeaderText="Designation" SortExpression="Designation"><EditItemTemplate>
<asp:TextBox ID="txtDesg" runat="server" Text='<%#Eval("Designation") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtDesg" runat="server"/>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemDesg" runat="server" Text='<%#Eval("Designation") %>'/>
</ItemTemplate>
</asp:TemplateField>--%>
<%--<asp:TemplateField HeaderText="Department" SortExpression="Department"><EditItemTemplate>
<asp:TextBox ID="txtDep" runat="server" Text='<%#Eval("Department") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtDep" runat="server"/>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemDep" runat="server" Text='<%#Eval("Department") %>'/>
</ItemTemplate>
</asp:TemplateField>--%>
 
<asp:TemplateField HeaderText="Department" HeaderStyle-HorizontalAlign="Left" SortExpression="Department">
<ItemTemplate><%# Eval("Department") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlDep" runat="server" SelectedValue='<%# Eval("Department").ToString() %>'>
<asp:ListItem Selected="True">Select Department</asp:ListItem>
<asp:ListItem Text="Accounts" Value="Accounts"></asp:ListItem>
<asp:ListItem Text="Sales" Value="Sales"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlDep" runat="server">
<asp:ListItem Selected="True">Select Department</asp:ListItem>
<asp:ListItem Text="Accounts" Value="Accounts"></asp:ListItem>
<asp:ListItem Text="Sales" Value="Sales"></asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
 
<asp:TemplateField HeaderText="Salary" HeaderStyle-HorizontalAlign="Left"><EditItemTemplate>
<asp:TextBox ID="txtSal" runat="server" ValidationGroup="Add New" Text='<%#Eval("Salary") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSal" runat="server" ValidationGroup="Add New"/>
<asp:RequiredFieldValidator ID="ReqGV5" runat="server" ValidationGroup="Add New"
        ControlToValidate="txtSal"
        ErrorMessage=" Enter salary with numeric values"></asp:RequiredFieldValidator>
<span>
    <asp:RangeValidator ID="RangeGV1" runat="server"
        Type="Double" ValidationGroup="Add New" ControlToValidate="txtSal"
        MinimumValue="10000.00" MaximumValue="60000.00"
        ErrorMessage =" Must be in the range between 20000.00 to 50000.00"></asp:RangeValidator></span>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemSal" runat="server" Text='<%#Eval("Salary") %>'/>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:TemplateField HeaderText="Gender" SortExpression="Gender"><EditItemTemplate>
<asp:TextBox ID="txtGen" runat="server"  Text='<%#Eval("Gender") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtGen" runat="server"/>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemGen" runat="server" Text='<%#Eval("Gender") %>'/>
</ItemTemplate>
</asp:TemplateField>--%>
 
<asp:TemplateField HeaderText="Gender" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Gender")%>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID="RBLGender" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Eval("Gender") %>'>
<asp:ListItem Value="Male">Male</asp:ListItem>
<asp:ListItem Value="Female">Female</asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
<FooterTemplate>
<asp:RadioButtonList ID="RBLGender" runat="server">
<asp:ListItem Value="Male">Male</asp:ListItem>
<asp:ListItem Value="Female">Female</asp:ListItem>
</asp:RadioButtonList>
</FooterTemplate>
</asp:TemplateField>
 
<%--<asp:TemplateField HeaderText="Preference"  SortExpression="Preference"><EditItemTemplate>
<asp:TextBox ID="txtPref" runat="server" Text='<%#Eval("Preference") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPref" runat="server"/>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblitemPref" runat="server" Text='<%#Eval("Preference") %>'/>
</ItemTemplate>
</asp:TemplateField>--%>
 
<asp:TemplateField HeaderText="Preference" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate><%# Eval("Preference") %></ItemTemplate>
<EditItemTemplate>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" SelectedValue='<%# Eval("Preference").ToString() %>'>
<asp:ListItem>Coffee</asp:ListItem>
<asp:ListItem>Tea</asp:ListItem>
<asp:ListItem>Cool Drink</asp:ListItem>
</asp:CheckBoxList>
</EditItemTemplate>
<FooterTemplate>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>Coffee</asp:ListItem>
<asp:ListItem>Tea</asp:ListItem>
<asp:ListItem>Cool Drink</asp:ListItem>
</asp:CheckBoxList>
</FooterTemplate>
</asp:TemplateField>
Posted 28-Nov-12 19:33pm
Comments
__TR__ at 29-Nov-12 1:54am
   
Don't split your code into 2 questions. Use the "Improve question" widget to update your old question and include this code in the same question. After you have updated the old question please delete this one.

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

  Print Answers RSS
0 OriginalGriff 210
1 Richard MacCutchan 100
2 kbrandwijk 90
3 ProgramFOX 80
4 Mukesh Bhagat 65
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100