Can i add two datakeynames to the datagrid

Posted on 2006-06-01
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
    LVL 7

    Expert Comment

    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

    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

    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now