Sometimes you need a way in which you don't want end user to edit some columns of gridview. There is no direct way for this. But you can achieve this with the help of CSS functionality.
STEP 1: Add the Following CSS class to the .aspx file
STEP 2: Set the CSSClass property of the cells in the GridView RowDatabound event as shown below.
Happy Coding!!
STEP 1: Add the Following CSS class to the .aspx file
<style type="CSS/Text">
td.freezecolumn{
text-align: left;
border-width:0;
position:relative;
cursor: default;
left:inherit;
}
</style>
STEP 2: Set the CSSClass property of the cells in the GridView RowDatabound event as shown below.
protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)This way you can freeze the column or you can say non-editable column in gridview.
{
e.Row.Cells[1].CssClass = "freezecolumn";
}
Happy Coding!!
No comments:
Post a Comment