By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

DataGrid hidden field

P: n/a
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.

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try to add something like this in Page_Load:

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

/Klas
-----Original Message-----
Hi everyone,

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


Nov 18 '05 #2

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

<asp:BoundColumn DataField="RowID" HeaderText="RowID" visible="False"></asp:BoundColumn>
Nov 18 '05 #3

P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:BB**********************************@microsof t.com...
Add a Databound column to the grid with attribute: visible = false like this:
<asp:BoundColumn DataField="RowID" HeaderText="RowID"

visible="False"></asp:BoundColumn>
Nov 18 '05 #4

P: n/a
If you want to reach the field at client, use <TemplateItem> with <input type=hidden>
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.