Hi, i would use the RowDataBound method of the grid. Analize your data and then disable the control as you wish.
Grid Code:
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
onrowdatabound="GridView1_RowDataBound">
<columns>
<asp:boundfield datafield="Name" headertext="Name" />
<asp:commandfield showeditbutton="True" />
</columns>
</asp:gridview>
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
DataTable tbl = new DataTable("data");
tbl.Columns.Add("Name");
DataRow row = tbl.NewRow();
row["Name"] = "Luis";
DataRow row2 = tbl.NewRow();
row2["Name"] = "Carl";
tbl.Rows.Add(row);
tbl.Rows.Add(row2);
this.GridView1.DataSource = tbl;
this.GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (((System.Data.DataRowView)(e.Row.DataItem)).Row[0].Equals("Luis"))
{
((WebControl)((System.Web.UI.WebControls.TableRow)(e.Row)).Cells[1].Controls[0]).Enabled = false;
}
}
}
I hope it help you. Regards.