473,756 Members | 7,817 Online
Bytes | Software Development & Data Engineering Community
+ 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"
AutoGenerateCol umns="False" >
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:Checkbox ID="chkSelectio n" Runat="server"> </asp:Checkbox>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Firs tName"
HeaderText="Fir stName"></asp:BoundColumn >
<asp:BoundColum n DataField="Last Name"
HeaderText="Las tName"></asp:BoundColumn >
</Columns>
</asp:datagrid>

Ex. something like
<asp:BoundColum n DataField="Firs tName"
HeaderText="Fir stName"></asp:BoundColumn >
<asp:BoundColum n DataField="Last Name"
HeaderText="Las tName"></asp:BoundColumn >
<input type="hidden" name="myhidden" value="<%#
DataBinder.Eval (Container.Data Item, "RowID") %>" runat=server"> which
doesn't work

Any idea?

Thank you
Maz.

Nov 18 '05 #1
4 1703
Try to add something like this in Page_Load:

DataGrid1.table s(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:BoundColum n DataField="RowI D" HeaderText="Row ID" 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:BoundColum n DataField="RowI D" >
<ItemStyle CssClass="Invis ible"></ItemStyle>
</asp:BoundColumn >
....
</body>

Eliyahu

"Dan B" <an*******@disc ussions.microso ft.com> wrote in message
news:BB******** *************** ***********@mic rosoft.com...
Add a Databound column to the grid with attribute: visible = false like this:
<asp:BoundColum n DataField="RowI D" HeaderText="Row ID"

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
5419
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" AutoGenerateColumns="False" > <Columns> <asp:TemplateColumn> <ItemTemplate>
3
4884
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 the best method? Do you have a sample of how to do this?
5
4955
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 the grid is in edit mode I hide the footer. The problem is when the datagrid footer is hidden the required field validator of my user controls fails validation even though the control is hidden. I am totally confused with this any help is greatly...
2
2655
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 row, that is in a hidden field on the datagrid. How can I do this? I would appreciate a simple answer (if one exists) as you may notice I'm new to this :p
2
4248
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" runat="server" value='<%# DataBinder.Eval(Container, "DataItem.item_id").ToString() %>'> I can get around that using an asp.net textbox control, but it doesn't
5
2791
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 to the database to get the next page. Is there a way to use the dataset to allow us to read back and forth in it instead of going back to the database to get it? Thanks,
13
2670
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. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
3
1711
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 Template Columns, into which I put buttons. When the user clicks on the 'Do It' button, the selection is recorded in an underlying database, and (almost) everything is fine. One thing I would like to improve in the existing version concerns...
3
3770
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 panel control in the OnInit method of the aspx Page. I am trying to implement a bidirectional sorting. I have a SortCommand method which fires OK. I have followed the code example given on the 4GuysFromRolla site, which reads the value from...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.