Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Retrieve DataKey field from Datagrid

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?

Cheers

Wayne
0
watherton
Asked:
watherton
  • 2
1 Solution
 
Jokra_the_BarbarianCommented:
All you would need is an event handler for the image button click. To retrieve a value from a specific datagrid cell:

     MessageBox.Show(this.dgMyDatagrid[this.dgMyDatagrid.CurrentRowIndex,1].ToString());

Or more generically:
     DATAGRIDNAME[ROWINDEX,COLUMNNUMBER].ToString()

0
 
wathertonAuthor Commented:
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"
      DataNavigateUrlField="ItemKey"
      DataNavigateUrlFormatString="window.open('about:blank','MoreInfo.aspx?id={0}', 'toolbar=no, scrollbars=no,menubar=no,width=500,height=100')"
      DataTextField="ItemKey"
      DataTextFormatString="View More">                                                      
</asp:HyperLinkColumn>
0
 
Jokra_the_BarbarianCommented:
I think you're missing: javascript:varwin=window.open

try this..

<asp:HyperLinkColumn
     DataNavigateUrlField="ItemKey"
     DataNavigateUrlFormatString="javascript:varwin=window.open('about:blank','MoreInfo.aspx?id={0}', 'toolbar=no, scrollbars=no,menubar=no,width=500,height=100')"
     DataTextField="ItemKey"
     DataTextFormatString="View More"                                            
/>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now