0

I'm trying to assign a css class to gridview row, but it does nothing. Code:

ImageButton button = (ImageButton)sender;
GridViewRow gvr = (GridViewRow)button.NamingContainer;
gvr.Attributes["class"] = "animated fadeOutRight";

What's wrong?

4
  • Have you debugged it, is the event triggered at all? Commented Nov 29, 2016 at 8:27
  • yes, event is triggering Commented Nov 29, 2016 at 8:33
  • Have you looked at the rendered HTML, if the css is applied to the row? Commented Nov 29, 2016 at 8:35
  • yes i have, css is not applied Commented Nov 29, 2016 at 8:42

1 Answer 1

1
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.CssClass = "animated fadeOutRight";
        }
    }

Css must be applied in RowDataBound only

Sign up to request clarification or add additional context in comments.

2 Comments

Well, he want to change css in the button-click event and only for this row
I need it to fade out after i press delete

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.