Some times you may want to edit items in a GridView control but you don't want every column to be editable. To do this you need to set the READONLY property to false.
ex)asp:boundfield visible="false">"
The columns that you want to edit you need to create a
instead of using the and set the contorls (one to manage the data and one to enable the edit row index by postback) that will handle the edit in the . In the example below, I have a which will handle the edit and a to postback and edit the GridView.
EditIndex property. You will have to rebind the grid for the edit template to display. Below
EditIndex property. You will have to rebind the grid for the edit template to display. Below
Ex)
"
<asp:BoundField ReadOnly="true" DataField="PPemployeeid" HeaderText="EMPID" SortExpression="PPemployeeid" HeaderStyle-ForeColor="Black" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-Width="50px"/>
Functional Title
Edit
"
"
<asp:BoundField ReadOnly="true" DataField="PPemployeeid" HeaderText="EMPID" SortExpression="PPemployeeid" HeaderStyle-ForeColor="Black" HeaderStyle-Wrap="false" ItemStyle-Wrap="false" ItemStyle-Width="50px"/>
--Code Behind--
protected void lkbEditFT_OnClick(object sender, EventArgs e)
{
this.gvData.EditIndex = 2;
this.gvData.DataSource = myData.Tables[0];
this.gvData.DataBind();
}
The grid should look like this after postback