Can i add two datakeynames to the datagrid

Posted on 2006-06-01
Medium Priority
Last Modified: 2009-04-01
I have a gridview with 3 columns invisible and
i need to get the values of the cells of the selected row. will it be possible to get the hidden column cell values by adding them to the datakeynames attribute.
Can anybody help me with the code.

Thnx in Advance
Question by:de1209

Expert Comment

ID: 16811005
Hidden cells are still in the index so you can access the value from the column index.

grid.rows[grid.SelectedIndex].Cells[colindex].Text; // where colindex is the index of your hidden column.

hope this helps.


Author Comment

ID: 16811053
I got it
Here is the solution :
Can hide as many columns as we want - but they should be added to datakeynames attribute in gridview if we wanted to get the cell values for these hidden columns.
They can be accessed using

GridView.DataKeys(index)(number of the datakeyname).ToString


Accepted Solution

DarthMod earned 0 total points
ID: 17174838
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question