473,698 Members | 2,196 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 2061
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
3342
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
15055
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
4878
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
2376
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
2459
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
3695
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
3438
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
2241
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
9157
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...
1
8895
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,...
0
8861
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...
0
7725
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
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
4369
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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.