3

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

4

3 回答 3

3

在网格 RowDataBound 事件中:

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");
        }
    }
于 2013-02-20T11:17:26.413 回答
1

在 GridView1_RowDataBound 事件中,对不需要值的行执行以下操作。

    for (int i = 0; i < e.Row.Cells.Count; i++)
        {
             e.Row.Cells[i].Text = "";
        }
于 2013-02-20T10:56:34.263 回答
0

您可以这样做是 DataBinding 事件。

protected void GRIDVIEW_DataBinding(object sender, EventArgs e)
{
   foreach(GridViewRow grv in GRIDVIEW.Rows)
   {
     grv.Visible = (Condition_to_check_if_value_loaded_is_zero);
   }
}
于 2013-02-20T20:59:27.633 回答