473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2043
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.com 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="DatabaseFieldName or whatever"
value='<%# DataBinder.Eval(Container.DataItem, "DatabaseFieldName") %>'>

How to get the value at runtime?
HtmlInputHidden hinputDatabaseFieldName
=((HtmlInputHidden)e.Item.FindControl("DatabaseFie ldName"));
//e=DataGridCommandEventArgs
long aLongValue=Int64.Parse(hinputDatabaseFieldName.Val ue); //you might
check hinputDatabaseFieldName against null in case the column does not
exist.

Hope this help.
Prodip

"me" <wt*****@forum.dk> wrote in message
news:6f**************************@posting.google.c om...
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="ID">
</asp:datagrid>

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

id = mygrid.DataKeys[mygrid.EditItemIndex];

PL.
"me" <wt*****@forum.dk> wrote in message news:6f**************************@posting.google.c om...
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
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...
4
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...
3
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...
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...
3
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...
2
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...
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...
5
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...
2
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...
6
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.