DataGrid hidden field

  • Thread starter Maziar Aflatoun
  • Start date
M

Maziar Aflatoun

Hi everyone,

I have the following code and I like to add a hidden field in each row

<asp:datagrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 48px; POSITION:
absolute; TOP: 40px" runat="server"
AutoGenerateColumns="False" >
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Checkbox ID="chkSelection" Runat="server"></asp:Checkbox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="FirstName"
HeaderText="FirstName"></asp:BoundColumn>
<asp:BoundColumn DataField="LastName"
HeaderText="LastName"></asp:BoundColumn>
</Columns>
</asp:datagrid>

Ex. something like
<asp:BoundColumn DataField="FirstName"
HeaderText="FirstName"></asp:BoundColumn>
<asp:BoundColumn DataField="LastName"
HeaderText="LastName"></asp:BoundColumn>
<input type="hidden" name="myhidden" value="<%#
DataBinder.Eval(Container.DataItem, "RowID") %>" runat=server"> which
doesn't work

Any idea?

Thank you
Maz.
 
K

Klas L

Try to add something like this in Page_Load:

DataGrid1.tables(0).columns(4).visible = false

/Klas
 
G

Guest

Add a Databound column to the grid with attribute: visible = false like this

<asp:BoundColumn DataField="RowID" HeaderText="RowID" visible="False"></asp:BoundColumn>
 
E

Eliyahu Goldin

As far as I remember, setting visible="False" results in not sending the
column to the client. If you want the column to get sent to the client. hide
is with a style rule like this:
<head>
....
<style type="text/css">
..Invisible {display:none}
</style>
....
</head>
<body>
....
<asp:BoundColumn DataField="RowID" >
<ItemStyle CssClass="Invisible"></ItemStyle>
</asp:BoundColumn>
....
</body>

Eliyahu

Dan B said:
Add a Databound column to the grid with attribute: visible = false like this:

<asp:BoundColumn DataField="RowID" HeaderText="RowID"
visible="False"></asp:BoundColumn>
 
G

Guest

If you want to reach the field at client, use <TemplateItem> with <input type=hidden>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top