473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DATAGRID WITH HIDDEN ID COLUMN?

me
I have a column in my datagrid showing the
unique identifier of the rows from the database.
I want to hide it but if I switch "visible" off in
visual studios property builder for datagrids then
the column is removed completely. I still need to
access the ID programmably on Update events (its
an editable datagrid). How do I achieve that?
Nov 18 '05 #1
3 2064
me wrote:
I have a column in my datagrid showing the
unique identifier of the rows from the database.
I want to hide it but if I switch "visible" off in
visual studios property builder for datagrids then
the column is removed completely. I still need to
access the ID programmably on Update events (its
an editable datagrid). How do I achieve that?

Check out the lovely DataGridGirl.co m and go to articles, there you'll
find http://www.aspalliance.com/aldotnet/...mnarticle.aspx

//Rutger
Nov 18 '05 #2
You can't hide the asp control. If you set the visible property of an asp
control, you would have nothing rendered on the client. Generic Html control
is the solution--

If are trying to hide a column in a grid, use something like this in the
grid's column template:
<input type="hidden" runat="server" id="DatabaseFie ldName or whatever"
value='<%# DataBinder.Eval (Container.Data Item, "DatabaseFieldN ame") %>'>

How to get the value at runtime?
HtmlInputHidden hinputDatabaseF ieldName
=((HtmlInputHid den)e.Item.Find Control("Databa seFieldName"));
//e=DataGridComma ndEventArgs
long aLongValue=Int6 4.Parse(hinputD atabaseFieldNam e.Value); //you might
check hinputDatabaseF ieldName against null in case the column does not
exist.

Hope this help.
Prodip

"me" <wt*****@forum. dk> wrote in message
news:6f******** *************** ***@posting.goo gle.com...
I have a column in my datagrid showing the
unique identifier of the rows from the database.
I want to hide it but if I switch "visible" off in
visual studios property builder for datagrids then
the column is removed completely. I still need to
access the ID programmably on Update events (its
an editable datagrid). How do I achieve that?

Nov 18 '05 #3
PL

You don't need to show the ID column, just set the DataKeyField property
of the datagrid to your ID field, i.e:

<asp:datagrid id="mygrid" DataKeyField="I D">
</asp:datagrid>

Then in your code use the DataKeys array when editing,
for example:

id = mygrid.DataKeys[mygrid.EditItem Index];

PL.
"me" <wt*****@forum. dk> wrote in message news:6f******** *************** ***@posting.goo gle.com...
I have a column in my datagrid showing the
unique identifier of the rows from the database.
I want to hide it but if I switch "visible" off in
visual studios property builder for datagrids then
the column is removed completely. I still need to
access the ID programmably on Update events (its
an editable datagrid). How do I achieve that?

Nov 18 '05 #4

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

Similar topics

1
4287
by: Derek | last post by:
Another DGrid question... I can not access the values of a cell in a datagrid unless I make them visible. I do not want these fields displayed. I only want to use the values to run a stored procedure off of. I access them right now using the item.cell().control method. Here's the code:
4
3343
by: chris | last post by:
Hello group, The datagrid I use needs to add a hidden column on demand (only on certain conditions). The sequence of events would be as below: 1) get the dataset(ds) and bind the datagrid(dg) with the table corresponding to the ds. 2) Sort the datagrid according to the user selected columns. 3) Add hidden columns to the datagrid. Here, I am not sure, how to add hidden columns to the datagrid??
3
15056
by: Brad | last post by:
I'm working with a DataGrid in C#, and the user needs to be able add and remove columns from the DataGrid on the fly, without opening and closing the form. The scenario is this. I have a setup table that allows users to rename columns, resize columns, and select whether or not they want them to be visible or not. While the user is working with a certain set of data, they will want to see certain columns, and in certain situations they...
3
4879
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?
3
2377
by: Ryan Riddell | last post by:
I am using the DataGrid control from 4guys (http://aspnet.4guysfromrolla.com/demos/RowHighlighter.aspx). I want to display 2 columns and allow editing. The only column I want the user to be able to change is the second column. I made this work via ReadOnly="true" for the first column. The second requirement is that the grid stores 2 table primary key values in columns 3 and 4. These columns will mean nothing to the user and could...
2
2462
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server checkbox control. where i'm at: i can retrieve a count of the selected checkboxes, but don't know how to get the related id's (in the 1st column).
2
2654
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
5
3698
by: Rich | last post by:
I have a datagrid that uses a dataview object for its datasource. The dataview contains a unique row identifier column. I don't want to display this column in the datagrid. I need the unique row Identifier column so that I can run updates on the SqlAdapter object. Is there a way to hide this column from the datagrid? Dim dv1 As New DataView(ds.Tables("tbl1")) dv1.AllowNew = False dgr1.DataSource = dv1 '--dgr1 is the datagrid
2
3442
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3 datagrida. I would like to set it so that if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to green if value of column 3 in datagrid 2 is < 90 set to red, if >= 90 set to green if value of column 3 in datagrid 3is < 80 set to red,...
6
2245
by: Doug Bell | last post by:
Hi I have a DataGrid with some hidden columns and also some read Only and some ComboBox Columns. Sandard Tabbing through the Datagrid sees the focus go to the hidden columns requiring further Tabbing to get to the desired column but it works fine stopping correctly on the ComboBox column. I have built a routine to test whether the use is Tabbing forward or back (Shift Tab) by looking at the last location, not by trapping the Keys. If
0
8889
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
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
4519
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...
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.