datagrid - accessing data in a row

G

gregoryenelson

Hi.

I am sitting here in a company with many people, but no othe
programmers least of all asp.net ones.

I have created a 'view' form on the INTRAnet, where many lines ar
displayed in a datagrid (SeLECT statement built in code and the Datase
bound to datagrid).

I just need to allow the user to click a row, whereupon I take the ke
from a field in that row and open up a Detail page.

I cannot find a way. OK, there is clientside and serverside scope, bu
there must be a way to do this.

Possible?

Help greatly appreciated.

Gre


-
gregoryenelso
 
E

Eliyahu Goldin

Greg,

On server side use ItemDataBound event to setup a javasript onclick event
handler for every cell in the row. Example:

private void dgList_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
e.Item.Attributes["onclick"] = "onRowClick(this)";
}

On client side in onRowClick(this) change the row visual properties to make
it visualy selected and save the key column value in a variable. If the grid
doesn't show the key value, pass it in an invisible column. When you need to
open the detail page, do it with showModalDialog call and pass the saved key
as a parameter.

Eliyahu
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top