allelopath
asked on
Display or not a button in DataGrid-ButtonColumn
I have a DataGrid with a column as a ButtonColumn. I need to display or not the button on a row-by-row basis based on data in the data binding. How do I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep. Will work exactly the same.
ASKER
Working on it. I have the asp setup, but not sure what to do with the btnDelete_DataBinding() method. The DataGrid data source is bound to a System.Collections.Generic .List<MyOb jects>, so somehow this gets used in the method:
protected void btnDelete_DataBinding(object sender, System.EventArgs e)
{
Button btn = (Button)(sender);
btn.Entable = true;
if (myObjectList (current element?).ACertainField.toString().Equals("someState")) {
btn.Entable = false;
}
}
the if statement above being the critical part. Can you suggest what to do ?
ASKER
Also I get this run-time error:
Parser Error Message: System.Web.UI.WebControls. DataGridCo lumnCollec tion must have items of type 'System.Web.UI.WebControls .DataGridC olumn'. 'asp:TemplateField' is of type 'System.Web.UI.WebControls .TemplateF ield'.
Parser Error Message: System.Web.UI.WebControls.
ASKER
It does not work exactly the same. With a DataGrid, one must use <asp:TemplateColumn>
ASKER