views:

25

answers:

2

Hi,

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?

Thanks,

A: 

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.

Ed B
But isn't the visible set to false fields are not rendered in asp.net?
burak ozdogan
doh..yes you're right.Then you can leave the column visible, but only to a width of 1px. The hidden input fields don't take up space.
Ed B
+1  A: 

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;}
Jakob Gade