2017-08-25 8 views
-1

異なる単一のトグルボタンを使用して特定の行をグリッド表示で表示/非表示するにはどうすればよいですか?たとえば、ボタンをクリックすると、グリッドビューの3番目の行が非表示になり、再度クリックするとその行が表示されます。ここで異なるボタンを使用して特定の行をグリッド表示で非表示にする

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

関連する問題