如何在 html 表格行中存储附加值并隐藏这些值以使其不显示?

发布于 2024-09-07 11:57:22 字数 259 浏览 1 评论 0原文

我想在每个 html 表行中存储一些对用户不可见的业务标志(例如:isFavorite、isOnLive 等)。

实际上,我的代码隐藏中有一个简单的 ADO.Net DataTable,用作 asp.Net GridView 控件的数据源。

该表的第 0、1、2 列包含一些业务标志。

我需要将这些列存储在网格视图的渲染 HTML 上,以便我可以通过 JavaScript 访问它们,但我不希望它们可见。

您能为我推荐这种情况的最佳实践吗?

I would like to store some business flags (like: isFavorite, isOnLive etc.) per an html table row that won't be visible to user.

In practice, I have a simple ADO.Net DataTable on my code-behind which is used as a data-source for a asp.Net GridView control.

This table contains some business flags on its 0th, 1st, 2nd columns.

I need to store those columns on the rendered HTML of the grid-view -so that I can reach them via JavaScript- but I do not want them to be visible.

Can you recommend me the best practice for such a case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤寂小茶 2024-09-14 11:57:22

为单元格指定样式以隐藏它们:

<tr>
  <td>Cell 1</td>
  <td>Cell 2</td>
  <td>Cell 3</td>
  <td class="hidden">Cell X</td>
</tr>

在样式表中:

td.hidden {display: none;}

Assign a style to the cells to hide them:

<tr>
  <td>Cell 1</td>
  <td>Cell 2</td>
  <td>Cell 3</td>
  <td class="hidden">Cell X</td>
</tr>

In your style sheet:

td.hidden {display: none;}
如若梦似彩虹 2024-09-14 11:57:22

您可以将它们设置在网格视图模板列的隐藏输入字段中。只需将列设置为不可见即可。

您可以在 javaScript 中找到隐藏的控件并使用其值。

You can set them in hidden input fields in a template column in your gridview. Just set the column to not visible.

You can find the hidden controls in javaScript and use its' values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文