Link to home
Start Free TrialLog in
Avatar of watherton
watherton

asked on

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
Avatar of Jokra_the_Barbarian
Jokra_the_Barbarian
Flag of United States of America image

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()

Avatar of watherton
watherton

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of Jokra_the_Barbarian
Jokra_the_Barbarian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial