3

I have a GridView from which i want to Show the GridColumn on Button Click.

enter image description here The Column with 'Source' i want to display on Button click using Javascript.

Note:The Button that we click to visible the column is outside the GridView.

<asp:TemplateField HeaderText="Source" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
    HeaderStyle-HorizontalAlign="Center">
    <ItemTemplate>
 <asp:Button ID="BtnSource" runat="server" CausesValidation="false" OnClick='<%# "return SetRowValues("+Eval("ttppcid")+",this.id,"+Eval("Fair")+","+Eval("Good")+","+Eval("Mint")+","+Eval("Poor")+","+Eval("Broken")+")"%>' Text="Source" />
  </ItemTemplate>
</asp:TemplateField>

Help Appreciated!

1 Answer 1

7

try this,

Add JavaScript in your page.

<script type="text/javascript">
    function hideColumn() {
        var gridrows = $("#GridView1 tbody tr");

        for (var i = 0; i < gridrows.length; i++) {
            gridrows[i].cells[1].style.display = "none";
        }
        return false;

    };
</script>

cells[1] instead of you can use your column number. and call this function on OnClientClick="Javascript:return hideColumn();" event.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.