473,756 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to put some hidden column in a DataGrid?

hi, all
I got another quesiton, in my DataGrid control, I want to have a hidden
column which will contian an ID value, I don't want to display this ID value
to user, but I need it when user click it. The problem I got is when I
uncheck the "visible" checkbox, it seems DataGrid does not render it at all.
So how to do this hidden column?
Thanks
Nov 19 '05 #1
4 1433
Hi.
I always put my ID's in a label:
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:Label id="lblID" runat="server" Visible="False" Text='<%#
DataBinder.Eval (Container.Data Item, "id") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateCol umn>

You can get your ID's from codebehind, like this:
For Each dgi In arrayListDataGr idItems
..
myID = CType(dgi.FindC ontrol("lblID") , Label).Text
..
Next

Hope this helps,
Shawn

"Nicky" <Ni***@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com...
hi, all
I got another quesiton, in my DataGrid control, I want to have a hidden
column which will contian an ID value, I don't want to display this ID value to user, but I need it when user click it. The problem I got is when I
uncheck the "visible" checkbox, it seems DataGrid does not render it at all. So how to do this hidden column?
Thanks

Nov 19 '05 #2
Hi Nicky,

The autogenerated coulmns of DataGrid are not part og the columns
collection...so you can't hide those columns just as follows

MyDataGrid.Colu mns(1).Visible = False

So the place to handle this is in the ItemDataBound event of the Datagrid:

<asp:DataGrid id="MyDatagrid " runat="server" AutoGenerateCol umns="True"
OnItemDataBound ="MyDatagrid_On ItemDataBound"/>

Private Sub MyDataGrid_Item DataBound(s As Object, e As DatagridItemEve ntArgs)
e.Item.Cells(1) .Visible = False
End Sub
Cheers,

Jerome. M
"Nicky" wrote:
hi, all
I got another quesiton, in my DataGrid control, I want to have a hidden
column which will contian an ID value, I don't want to display this ID value
to user, but I need it when user click it. The problem I got is when I
uncheck the "visible" checkbox, it seems DataGrid does not render it at all.
So how to do this hidden column?
Thanks

Nov 19 '05 #3
Hey Nicky,

If you are defining your columns in the ASPX page then try this out :-

<Columns>
<asp:BoundColum n Visible="False" DataField="Cand idateId"
HeaderText="Can didate Id">
<ItemStyle Height="10px" Width="10px"></ItemStyle>
</asp:BoundColumn >
<asp:ButtonColu mn Text="Select" DataTextField=" FullName"
SortExpression= "FullName" HeaderText="Ful l Name">
<ItemStyle Width="300px"></ItemStyle>
and you can access the first column by

candidateNo = e.Item.Cells[0].Text ;

*************** **************
Hope This Helps,
Shaun (M.C.P)

http://blogs.wwwcoder.com/shaunakp
*************** **************

"Nicky" wrote:
hi, all
I got another quesiton, in my DataGrid control, I want to have a hidden
column which will contian an ID value, I don't want to display this ID value
to user, but I need it when user click it. The problem I got is when I
uncheck the "visible" checkbox, it seems DataGrid does not render it at all.
So how to do this hidden column?
Thanks

Nov 19 '05 #4
Thta's right, if Visible=false the column doesn't get rendered. Hide it with
css style display:none.

Eliyahu

"Nicky" <Ni***@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com...
hi, all
I got another quesiton, in my DataGrid control, I want to have a hidden
column which will contian an ID value, I don't want to display this ID value to user, but I need it when user click it. The problem I got is when I
uncheck the "visible" checkbox, it seems DataGrid does not render it at all. So how to do this hidden column?
Thanks

Nov 19 '05 #5

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

Similar topics

2
17861
by: yaara | last post by:
Hi, I'm trying to define an extra column in an HTML table. The extra column should not be displayed. I added style="width:0%;visibility:hidden;" to its tag. Although I don't see the actual column I can see a large space at the end of the table (where the extra column was supose to be drawn).
1
2363
by: CodeToad | last post by:
I hope this is not a repost. Other computer hung when posting question. I have a datagrid, populated with 3 columns. col1=PK from database, and is hidden using gridcolumn styles. I need to retrieve the text of the PK in col1, row-n, and not sure how.
3
1299
by: Tom | last post by:
I have a gridView with a hidden column, I need to get that value from that hidden column and pass it to another page. is that possible if so how?
2
4716
by: denvercr | last post by:
Hi guys, I'm having a problem on this a couple of days ago.. I did the best I could but I end up nothing. you guys are my last resort.. How could I possibly retrieve a value of a hidden column in gridview? The column that is hidden is the primary key for security issue.. Hope you could help me out of this guys.. thanks for your good heart.
3
28537
by: denvercr | last post by:
Hi how do i possibly get the value of a hidden column (id) of a gridview binded in sqldatasource? i have this code in C# usng GridViewRow and DataKey Classes to retrieve it, I also set the DataKeyNames to "id".. here is the code: GridViewRow gridViewRow; DataKey dataKey; gridViewRow = GridView.SelectedRow; dataKey = GridView.DataKeys; Label1.text = Convert.ToString(dataKey.Value); // This should display id value.
2
1536
by: x taol | last post by:
i want to maintain a hidden column in datasheet. Anybody can show the hidden column how drag column heading with mouse. i want to prohibit the method from anybody. *** Sent via Developersdex http://www.developersdex.com ***
0
1286
by: Slickuser | last post by:
Is there a way to get values from GridView when it's a hidden Column. This code work if my column is set Visible to true. DropDownList ddl = (DropDownList)sender; GridViewRow row = (GridViewRow)ddl.NamingContainer; DropDownList dropdownlist = ((DropDownList)row.FindControl("aDropList"));
1
2482
by: vignahari | last post by:
Hai Friends I n my case i am reterieving some datas from the backend in that one patricular column in the gridview should be hidden.it should not shown in the screen.in case if is use visible="false" the datas not showing in when clicking the event the text box how to do this pls help me. source code: --------------------------------------------- <asp:BoundField DataField="GLAC_NAME" HeaderText="A/cNo"> <ItemStyle Width="200px" />...
2
2603
by: Blacky | last post by:
Hi, I am using c# asp.net application.I have datagrid which binds column dynamically and i make certain columns say visibility to false in my itemdatabound event EMPID AS E.ITEM.CELLS.VISIBLE = FALSE.Now i want to perform validations based on this value in cell using javascript... By clicking on one rows checkbox in datagrid, i need to color all other rows which has the same value in the hidden column EMP... IE cells.. function...
0
9456
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
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
10034
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
8713
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...
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
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.