Retrieve DataKey field from Datagrid

Posted on 2004-11-22
Last Modified: 2010-04-15
Hi guys, I have a datagrid that comprises of information taken from a db.

The first col is hidden and retrieves the items id, the second col is a ImageButton. I do I click on the image button and retrieve its key in a code behind page?


Question by:watherton
    LVL 11

    Expert Comment

    All you would need is an event handler for the image button click. To retrieve a value from a specific datagrid cell:


    Or more generically:


    Author Comment

    Jokra I have sorted this out now, i was just about to delete this q.

    But maybe you could help me on this.

    How do i do the following:

    <asp:HyperLinkColumn runat="server"
          DataNavigateUrlFormatString="'about:blank','MoreInfo.aspx?id={0}', 'toolbar=no, scrollbars=no,menubar=no,width=500,height=100')"
          DataTextFormatString="View More">                                                      
    LVL 11

    Accepted Solution

    I think you're missing:

    try this..

         DataNavigateUrlFormatString="'about:blank','MoreInfo.aspx?id={0}', 'toolbar=no, scrollbars=no,menubar=no,width=500,height=100')"
         DataTextFormatString="View More"                                            

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now