Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide Gridview row values in asp.net

I have Gridview control with 21 rows.Some of the rows have 0 values.My requirement is to set background color(consist 0 values Rows) as well as hide the values(means 0's).I can able to set background color.But the thing is,I am not able to hide row values.I have written this line of code, gridSellIn.Rows[0].Visible = false; .Total row is hiding.Make sure i have to show rows back ground color without values.Is this possible in asp.net.enter image description here

like image 712
shankar.parshimoni Avatar asked Oct 14 '25 12:10

shankar.parshimoni


1 Answers

In the grid RowDataBound event:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (...){
            //hide controls
            foreach (Control c in e.Row.Controls)
            {
                 c.Visible=false;
            }
            //change color
            e.Row.Style.Add("background-color","red");
        }
    }
like image 65
Stefano Altieri Avatar answered Oct 17 '25 01:10

Stefano Altieri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!