Please tell me how to remove and add CssClass to a specific textbox inside gridview ?
This is what i have tried but it doesnot changee css for the textbox
my css in my .aspx page is :
<style type="text/css">
.erroramount
{
border:3px solid red
}
</style>
in my button click here is my code for gridview looping where depending upon the 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";
}
}
}
}
Anonymous User
18-Dec-2013I got the output by removing the existing (default) css class and adding this css class with textbox. it worked.
Here is the complete code