forum

Home / DeveloperSection / Forums / how to remove and add css class to a specific textbox inside gridview in c# asp.net?

how to remove and add css class to a specific textbox inside gridview in c# asp.net?

Anonymous User 6345 18-Dec-2013

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";
         }
     }
   }
 }

Updated on 18-Dec-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By