locked
Making Rows Invisible not working RRS feed

  • Question

  • User1944504294 posted

    Hi,

    please help.

    This code doesn't makes the rows InVisible 

    -----------------------------------------------------------

    if (gvitemsarray.Count() != 0)
    {
    for (int i = 0; i < gvitemslist.Count(); i++)
    {
    rowCount = 0;
    foreach (GridViewRow grd1Row in gvItems.Rows)
    {
    if (valueKeys[i].Equals(gvItems.DataKeys[rowCount].Values[1].ToString()))
    {
    grd1Row.Visible = false;   or grd1Row.Enabled = false; 
    }

    rowCount++;
    }

    }

    }

    Please help not worling.

    Best regards,
    Renuka.V

    Thursday, June 19, 2014 7:46 AM

Answers

  • User103196646 posted

    Thanks! I understand now - you want to:

    1. Loop through an Array List.
    2. Find the matching rows by Key value in a GridView.
    3. Make the matching Rows Invisible.
    private void LoopThroughArray()
    {
      for (i = 0; i < args.Count; i++)
      {
        var keyValue = args[i].ToString();
    
        // Call HideRow method
        HideRow(keyValue);
      }
    }
    
    private void HideRow(string KeyValue)
    {
      for (int i=0; i < gvItems.Rows.Count; i++)
    {
    if (row.Cells[1].Value == KeyValue)
    gvItems.Rows[i].Visible = false;
    }
    }

    Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 19, 2014 9:36 AM

All replies

  • User103196646 posted

    Hello! Thanks for your post!

    Here's the solution - you need to set gvItems.Rows[i].Visible = false;

    for (int i = 0; i < gvitemslist.Count(); i++)
    {
     rowCount = 0;
    
     foreach (GridViewRow grd1Row in gvItems.Rows)
     {
       if (valueKeys[i].Equals(gvItems.DataKeys[rowCount].Values[1].ToString()))
       {
         gvItems.Rows[i].Visible = false;
       }
    }

    Regards!

    Thursday, June 19, 2014 8:33 AM
  • User1944504294 posted

    Thanks,

    But that variable i counts the list not the rows in the GridViewRow, so it not works

    thanks for the syntax.

    Thursday, June 19, 2014 8:43 AM
  • User103196646 posted

    Thanks! I understand now - you want to:

    1. Loop through an Array List.
    2. Find the matching rows by Key value in a GridView.
    3. Make the matching Rows Invisible.
    private void LoopThroughArray()
    {
      for (i = 0; i < args.Count; i++)
      {
        var keyValue = args[i].ToString();
    
        // Call HideRow method
        HideRow(keyValue);
      }
    }
    
    private void HideRow(string KeyValue)
    {
      for (int i=0; i < gvItems.Rows.Count; i++)
    {
    if (row.Cells[1].Value == KeyValue)
    gvItems.Rows[i].Visible = false;
    }
    }

    Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 19, 2014 9:36 AM
  • User1944504294 posted

    Very Nice :-D

    Thanks a lot !

    Also got by..

    if (gvitemsarray.Count() != 0)
    {
    for (int i = 0; i < gvitemslist.Count(); i++)
    {
    rowCount = 0;
    foreach (GridViewRow grd1Row in gvItems.Rows)
    {
    if (valueKeys[i].Equals(gvItems.DataKeys[rowCount].Values[1].ToString()))
    {
    gvItems.Rows[rowCount].Enabled = false;
    }

    Best Regards,

    Renuka.V

    rowCount++;
    }
    }
    }

    Thursday, June 19, 2014 11:28 AM