2017-08-25 33 views
-1

如何使用不同的單一切換按鈕在網格視圖中隱藏/顯示特定的行?例如,如果我點擊一個按鈕,它將隱藏網格視圖的第三行,當我再次點擊它時,它將顯示該行。使用不同的按鈕在網格視圖中隱藏特定的行

enter image description here

這裏是我的aspx代碼:

<form id="form1" runat="server"> 
<div> 
    <button id="Button1" type="button" runat="server" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off"> 
     Transcript of Records 
    </button>     
    <button id="Button2" type="button" runat="server" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off"> 
     Checklist 
    </button>    
    <button id="Button3" type="button" runat="server" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off"> 
      Registration Form 
    </button> 
    <button id="Button4" type="button" runat="server" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off"> 
      Good Moral 
    </button> 
    <button id="Button5" type="button" runat="server" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off"> 
      Honorary Dismissal 
    </button> 
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> 
    <Columns> 
    <asp:BoundField DataField="Name" HeaderText="Name of Request" HeaderStyle-Width='100px'/> 
    <asp:BoundField DataField="TAT" HeaderText="Processing Time" HeaderStyle-Width='100px'/> 
    <asp:BoundField DataField="QTY" HeaderText="Quantity" HeaderStyle-Width='100px'/> 
    <asp:BoundField DataField="Price" HeaderText="Price" HeaderStyle-Width='100px'/> 
    <asp:BoundField DataField="Total" HeaderText="Total" HeaderStyle-Width='100px'/> 
    </Columns> 
    </asp:GridView>     
</div> 
</form> 

請問這個需要JavaScript的?

回答

0

你可以試試這個,但首先你需要確定你想要隱藏哪一行。

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)  
{  
    Label YourControl= (Label)e.Row.FindControl("YourControl");  
    if (YourControl != null)  
    {  
     if (YourControl.Text.Trim() == "0")  
     {  
      LinkButton YourControl= (LinkButton)e.Row.FindControl("YourControl");  
      YourControl.Visible = false;  
     } 

    } 

} 
+0

嗨,這是每個按鈕的代碼? – kelvin

+0

您可以在每個按鈕上綁定網格視圖,以便調用GridView1_RowDataBound,以便您可以在其中過濾文本。 – Ravikumar

+0

對不起,我是新來的,你從哪裏得到lblBalanceAmount? – kelvin

相關問題