Simple question

G

Gary

Hi,
I have 7 columns on my datagrid, out of which one column (Column No 1) is
hidden (which is containing User ID), and the Column No 3 is displaying user
Name.
Now I have given hyperlink on Column no 3 (i.e User Name) & I want to pick
up the data from Column no 1 (i.e User ID) when I click the hyperlink.

Please let me know how this can be done.

TIA,
Gary
 
A

ASP.NET

are you using the SelectedIndexChanged event? try something like this (C#):

int userID = (int) myDataGrid.DataKeys[myDataGrid.SelectedIndex];

This assumes you have set the DataKeyField property of your grid. Think of
DataKeys as your collection of IDs, one ID per row.

Regards,
Stephen
 
S

Sonali.NET[MVP]

How does your HyperlinkColumn look like
In case its
<asp:HyperLinkColumn HeaderText="UserName" DataNavigateUrlField="ID"
DataNavigateUrlFormatString="link.aspx?ID={0}"
DataTextField="UserName"></asp:HyperLinkColumn>
</Columns>

You can give the DataNavigateURL Field as Column 1 and DataTextField as column 3
In case of retrieving it you can use
Request.QueryString("ID")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top