Tevin Prinsloo

Tevin Prinsloo

  • NA
  • 4
  • 842

Hide/Show Repeater Control Column based on condition

May 28 2021 11:45 AM
I have a repeater control , a View button and a radio button with options Grams and Kilograms. When I tick th Gram radio button and click view then I want to Hide all kilogram columns and when I tick Kilograms and click View then all Gram columns must be hidden. Below is my code:
 
Repeater Control:
  1. <asp:Repeater ID="rpComponentWeightResults" OnItemDataBound="rpComponentWeightResults_ItemDataBound" runat="server">  
  2. <HeaderTemplate>  
  3. <table class="table table-striped table-bordered table-hover table-condensed" border="1">  
  4. <thead>  
  5. <tr>  
  6. <th>Date Captured</th>  
  7. <th>Stock Code</th>  
  8. <th>Description</th>  
  9. <th id="PartWeightGramHeader" runat="server">Part Weight (g)</th>  
  10. <th id="SprueWeightGramHeader" runat="server">Sprue Weight (g)</th>  
  11. <th id="PartWeightKgHeader" runat="server">Part Weight (kg)</th>  
  12. <th id="SprueWeightKgHeader" runat="server">Sprue Weight (kg)</th>  
  13. <th>Tolerance %</th>  
  14. <th id="BomWeightGramHeader" runat="server">Bom Weight (g)</th>  
  15. <th id="BomWeightKgHeader" runat="server">Bom Weight (kg)</th>  
  16. <th id="VarianceToSysproGramHeader" runat="server">Variance To Syspro (g)</th>  
  17. <th id="VarianceToSysproKgHeader" runat="server">Variance To Syspro (Kg)</th>  
  18. <th>Variance To Syspro (%)</th>  
  19. <th>Out Of Spec</th>  
  20. </tr>  
  21. </thead>  
  22. <tbody>  
  23. </HeaderTemplate>  
  24. <ItemTemplate>  
  25. <tr>  
  26. <td>  
  27. <asp:Label Text='<%# Eval("CapturedDateTime", "{0: dd/MM/yyyy}")%>' runat="server" ID="lblCaptureDate" />  
  28. </td>  
  29. <td>  
  30. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "StockCode")%>' runat="server" ID="lblStockCode" />  
  31. </td>  
  32. <td>  
  33. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "LongDesc")%>' runat="server" ID="lblLongDesc" />  
  34. </td>  
  35. <td id="PartWeightGramCol" runat="server">  
  36. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "PartWeightGram")%>' runat="server" ID="lblPartWeightGram" />  
  37. </td >  
  38. <td id="SprueWeightGramCol" runat="server">  
  39. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "SprueWeightGram")%>' runat="server" ID="lblSprueWeightGram" />  
  40. </td>  
  41. <td id="PartWeightKgCol" runat="server">  
  42. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "PartWeightKg")%>' runat="server" ID="PartWeightKg" />  
  43. </td>  
  44. <td id="SprueWeightKgCol" runat="server">  
  45. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "SprueWeightKg")%>' runat="server" ID="lblSprueWeightKg" />  
  46. </td>  
  47. <td>  
  48. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "TolerancePercentage")%>' runat="server" ID="lblTolerancePercentage" />  
  49. </td>  
  50. <td id="BomWeightGramCol" runat="server">  
  51. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "BomWeightGram")%>' runat="server" ID="lblBomWeightGram" />  
  52. </td>  
  53. <td id="BomWeightKgCol" runat="server">  
  54. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "BomWeightKg")%>' runat="server" ID="lblBomWeightKg" />  
  55. </td>  
  56. <td id="VarianceToSysproGramCol" runat="server">  
  57. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "VarianceToSysproGram")%>' runat="server" ID="lblVarianceToSysproGram" />  
  58. </td>  
  59. <td id="VarianceToSysproKgCol" runat="server">  
  60. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "VarianceToSysproKg")%>' runat="server" ID="lblVarianceToSysproKg" />  
  61. </td>  
  62. <td>  
  63. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "VarianceToSysproPct")%>' runat="server" ID="lblVarianceToSysproPct" />  
  64. </td>  
  65. <td>  
  66. <asp:Label Text='<%#DataBinder.Eval(Container.DataItem, "IsOutOfSpec")%>' runat="server" ID="lblIsOutOfSpec" />  
  67. </td>  
  68. </tr>  
  69. </ItemTemplate>  
  70. <FooterTemplate>  
  71. </tbody>  
  72. </table>  
  73. </FooterTemplate>  
  74. </asp:Repeater>  
ItemDataBound: (Not Sure What Code I Should Place Here)
  1. Protected Sub rpComponentWeightResults_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)  
  2. End Sub  

Answers (2)