Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i display my employee code in gridview which is retrived from database as non-editable cell and the other cell in which i'm going to enter newly as editable one?
the employee code column which i entered before should be default thing and should not be alter and the new employee code which i'm going to enter in the same column name should be editable cell as text box?....
Posted
Comments
S V Saichandra 2-Dec-11 5:49am    
can be more specific about your question. Do u want to show permanently the employee code even after editing or you want to just editable and uneditable feilds. If you want your first employee code to be always same then you must create two columns because after editing the value will be changed and if you want to display the editable read only feilds you can try below code:
Dinesh Mani 2-Dec-11 6:17am    
Why do you need to display your Emp id in a gridview? What else is to be displayed along with the Emp id? Why would you want to allow the user to edit employee id???
riodejenris14 2-Dec-11 6:21am    
i'm having five rows in a grid view in which i entered three rows which is updated to my database. if i want to enter a new row of data to the table the employee id column of the table should be displayed as read only and the cell employee id column of the new row should be writeable...

1 solution

XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="false">
    <Columns>
    <asp:TemplateField HeaderText ="EmpCode">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("EmpCode") %>'></asp:Label>
    </ItemTemplate>
// in this edit template your using a label and eval which cell as read only.
    <EditItemTemplate>
     <asp:Label ID="Label1" runat="server" Text='<%# Eval("EmpCode") %>'></asp:Label>
    </EditItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText ="EmpCode">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("EmpCode") %>'></asp:Label>
    </ItemTemplate>
// This edittemplate your using a textbox and bind method which makes the cell as editable by the user.
    <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EmpCode") %>'></asp:TextBox>
    </EditItemTemplate>

    </asp:TemplateField>
    </Columns>
    </asp:GridView>
 
Share this answer
 
v2

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