473,468 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataGrid hidden field

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
4 1691
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
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
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
If you want to reach the field at client, use <TemplateItem> with <input type=hidden>
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Maziar Aflatoun | last post by:
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"...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
5
by: Chamindu R Munasinghe | last post by:
Hi, I use the asp.net datagrid footer to add new records. In the footer I use a web user control to read a date. it is made of a text box, a required field validator and a compare validator. When...
2
by: Not Me | last post by:
Hi, In a datagrid's itemcommand method, I can use DataGridCommandEventArgs/item/cells/text to bring up a specific field from a row that was accessed. However, I wish to lookup data from that...
2
by: Rodusa | last post by:
I have a hidden field inside one datagrid which I can't get to make it keep its state after a postback event. Look field: <input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
3
by: Phillip N Rounds | last post by:
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to add some functionality to, and I can't figure out how to do int. The existing DataGrid has several databound columns and a...
3
by: Mark Gilkes | last post by:
Hi, I have an aspx page in which I am building a DataGrid control in the code-behind dynamically. The DataGrid is declared along with BoundColumns and bound to the datasource, then added to a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.