Neven,
Is the function on the client or server side?
If it is on the client, or even if it is on server, but you want to do
something on the client, for example highlighting the selected row, you can
take the following way.
Setup client side onclick event for items like in the following snippet:
private void dg_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"] = "onSelectRowClick(this)";
}
Client side function onSelectRowClick accepts a reference to the row. This
makes all cell values available on client side. Now, if you need to pass one
of them back to the server you can do it in one of several ways of passing
form data from client to server.
Eliyahu
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:ek****************@TK2MSFTNGP09.phx.gbl...
Hi,
I need to create the following ...
I have DataGrid filled with information (ID, name, price ...).
I need to call a function when I click on the item in the DataGrid (and
pass ID as an argument to that function). I tried to add DataGrid_ItemDataBound
function, but I can't add Command and CommandArgument properties to each
DataGrid Item.
Thanx, Neven