简体   繁体   English

我如何在不使用FindControl()方法的情况下,在后面的代码中使用位于gridView中的文本框的值

[英]How I can use the value of a textbox which is in a gridView in the code behind without using the FindControl() method

How can do I that? 我该怎么办? Does anyone have a solution. 有没有人有办法解决吗。 It is also looking tricky but I don't have an answer. 它看起来也很棘手,但我没有答案。

Did you try something like this? 你尝试过这样的事情吗?

((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]) ((文本框)GridView1.Rows [e.RowIndex] .Cells [0] .Controls [0])

 <script type="text/javascript">
  function SelectAll(id)
  {
    //get reference of GridView control
    var grid = document.getElementById("<%= GridView1.ClientID %>");
    //variable to contain the cell of the grid
    var cell;

    if (grid.rows.length > 0)
    {
      //loop starts from 1. rows[0] points to the header.
      for (i=1; i<grid.rows.length; i++)
      {
        //get the reference of first column
        cell = grid.rows[i].cells[0];

        //loop according to the number of childNodes in the cell
        for (j=0; j<cell.childNodes.length; j++)
        {       
          //if childNode type is textbox or label or...         
          if (cell.childNodes[j].type =="TextBox")
          {
          //perform ur task here
        }
        }
      }
    }
  }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在GridView的OnRowCommand中使用FindControl? - How can use FindControl in the OnRowCommand of GridView? 如何在JavaScript函数中使用/引用所选值(TextBox)到后面的C​​#代码中? - How can I use/reference the selected value (TextBox) from a JavaScript Function into C# Code behind? 如何在JavaScript设置的代码隐藏中获取文本框的值? - How to get value of textbox in code-behind which was set by Javascript? 如何获取代码背后的Raduploader动态创建的文本框的值? - How to get the value of the textbox which created dynamically with the Raduploader in code behind? 如何在代码后面使用GridView数据源不修剪文本? - How can I use the GridView datasource in code-behind to not trim text? 在GridView中使用FindControl无法获得控制 - can't get control using FindControl in GridView 如何通过使用后面的代码在Gridview的itemtemplate内的控件上添加只读属性? - How can I add readonly attribute at a control inside itemtemplate of Gridview by using code behind? 我可以在findcontrol中使用数组吗? - Can I use an array in findcontrol? 我该如何从gridview的行中的文本框中更改值? - How can i change value from textbox in row in gridview? 如何在代码隐藏中获取文本框的值 - How to get the value of a textbox in code-behind
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM