在客户端分配Gridview列并显示,但文本在代码隐藏时显示为黑色

时间:2017-06-16 04:24:27

标签: javascript c# jquery asp.net gridview

早上好。

我有一个gridview。我想将文本分配给其中一列 文本显示在网格中。但在codebind,文本是空白的。真诚地感谢任何帮助。

HTML:

<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False" >
<Columns>
    .....
        <asp:BoundField HeaderText="+/-" />
        <asp:BoundField DataField="w2do" HeaderText="What2Do" />
        ......
        </Columns>
</asp:GridView>

脚本:

function xx(grid) {
    for (i = 1; i < grid.rows.length; i++) {
        row = grid.rows[i];
        row.cells[1].val("+");      // give error
            row.cells[1].Text = "+";    // this way, text doesn't show up inthe grid.
            row.cells[1].innerHTML = "+";   // text shows up in the grid; but when I'm ready to use it at code behind, the text is not there.
    }
}

代码背后:

foreach (GridViewRow row in <asp:GridView {
    row.Cells[1].Text.ToString();       // text is empty

}

0 个答案:

没有答案