If you want server-side onclick event processing add a hidden column like
this:
<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"
Visible="False"></asp:ButtonColumn>
and handle ItemDataBound event like this:
protected void myGrid_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;
}
LinkButton button = (LinkButton) e.Item.Cells[0].Controls[0];
e.Item.Attributes["onclick"] = this.GetPostBackClientHyperlink
(button, "");
}
The example presumes the the column is the very first one in the grid.
Eliyahu
[quoted text, click to view] "JD" <jdnews@dalys.us> wrote in message
news:u72f%23vAOFHA.3828@TK2MSFTNGP10.phx.gbl...
> I originally did that but the client didn't like the idea of the button on
> the screen, they felt it was somewhat confusing to click on a button to
> select a record and then click on another button to save the change.
>
> Is it possible to make the datagrid work like a spreadsheet where you
select
> a row and highlight the selected row and then handle it appropiately.
>
>
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:346087632480834291633584@msnews.microsoft.com...
> > Add a button in your DataGrid, give it a CommandName="Click", then
handle
> > the DataGrid's ItemCOmmand event. If the
ItemCommandEventArgs.CommandName
> > matches your Button's COmmandName ("Click" in this case), then the
> > ItemCommandEventArgs.Item is the row that was clicked and its index in
the
> > DataGrid is ItemCommandEventArgs.Item.ItemIndex.
> >
> > -Brock
> > DevelopMentor
> >
http://staff.develop.com/ballen > >
> >
> >
> >> Hello Everyone,
> >>
> >> I am writing a asp.net page using vb.net with a datagrid control. I am
> >> trying to detect when a row is clicked on in the grid. And I am not
> >> sure how to do this, if anyone has any ideas on this I would really
> >> appreciate your help. Thanks.
> >>
> >
> >
> >
>
>