locked
How to get value of Visible Column on gridview RRS feed

  • Question

  • User-475949336 posted

    Hi

    I  have gridview as below:

    <asp:Gridview id="gridview2" CssClass="dt-responsive" class="display" Width="100%" runat="server" AutoGenerateColumns="false">

    ....

    <asp:TemplateField HeaderText="Code" Visible="false">
    <ItemTemplate>
    <asp:TextBox ID="txtMyCode" Text='<%# Eval("mycode") %>' runat="server" Visible="false"></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>

    .....

    </<asp:Gridview>

    AND below code in javascript (I must use function as that)

    function updateCaculate_addnew()
    {
    var table = $('#<%=gridview2.ClientID%>').DataTable();
    var rowCount = table.rows().count();

    var i;
    for (i = 0; i < rowCount; i++)

    {
    var selectorForMycode ='#<%=gridview2.ClientID%> input[id*=txtMyCode_' + i + ']';
    var mycode= $(selectorForMycode ).val();   // I can't get this, because 'txtMyCode' is Visible="false"


    }

    }

    pls help me ASAP, thanks very much!

    Wednesday, April 22, 2020 11:10 AM

Answers

  • User475983607 posted

    Dear mgebhard

    plse detail how to for me, I can't do it with the guide.

    You need assistance adding a hidden field to a GridView?  The process is the same adding a textbox server control.  Can explain why you are unable to add a hidden field?  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 22, 2020 11:44 AM

All replies

  • User475983607 posted

    The ASP.NET framework does not return HTML to the browser when the server control's visibility is set to false.  A possible solution is using CSS to set the display to none.

    .myDisplayNone {display:none;}

    You can also take advantage of a hidden field.

    Wednesday, April 22, 2020 11:21 AM
  • User-475949336 posted

    Dear mgebhard

    plse detail how to for me, I can't do it with the guide.

    Wednesday, April 22, 2020 11:23 AM
  • User475983607 posted

    Dear mgebhard

    plse detail how to for me, I can't do it with the guide.

    You need assistance adding a hidden field to a GridView?  The process is the same adding a textbox server control.  Can explain why you are unable to add a hidden field?  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 22, 2020 11:44 AM
  • User-475949336 posted

    Hi mgebhard

    I added hidden field to gridview2 and got the value of this column. I'm wrong when don't use hidden field.embarassed

    Thank you very much!!!

    Wednesday, April 22, 2020 3:15 PM