I need assistance with removing and adding a CssClass to a specific textbox within a gridview. I have attempted the following code but it does not update the css for the textbox.
Here is the CSS in my .aspx page:
<style type="text/css">
.erroramount
{
border:3px solid red
}
</style>
In my button click event, here is my code for looping through the gridview. Depending on a condition, I want to change the border color of the textbox:
var result = (from f in dtCloned.AsEnumerable()
group f by f.Field<string>("AssetDescription") into g
select
new
{
AssetDescription = g.Key,
TotalAmount = g.Sum(r => r.Field<double?>("Amount"))
});
foreach (var aAsset in result.AsEnumerable())
{
if (aAsset.TotalAmount < 0)
{
foreach (GridViewRow arow in GridProjectDetails.Rows)
{
string AssetDescription = ((TextBox)arow.FindControl("TextAssetDescription")).Text;
if (AssetDescription == aAsset.AssetDescription)
{
((TextBox)arow.FindControl("TextAmount")).CssClass = "erroramount";
}
}
}
}