Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Click anywhere in a row....

Reply
Thread Tools

Click anywhere in a row....

 
 
UJ
Guest
Posts: n/a
 
      05-12-2005
Is there any way to tell when a user clicks anywhere in a row? The only way
I can think to do it is to make each column a link with a button and use the
text as the value I want displayed.

TIA.


 
Reply With Quote
 
 
 
 
Sambathraj
Guest
Posts: n/a
 
      05-12-2005
Hi,
Try usng Onclick event for the TR
Regards
Sambath
"UJ" <> wrote in message
news:...
> Is there any way to tell when a user clicks anywhere in a row? The only
> way I can think to do it is to make each column a link with a button and
> use the text as the value I want displayed.
>
> TIA.
>
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      05-12-2005
There is a number of ways. The easiest one (C# syntax):

Add a hidden button column:

<asp:datagrid id=myGrid runat="server" AutoGenerateColumns="False"
OnItemDataBound="myGrid_ItemDataBound" >
<Columns>
<asp:ButtonColumn ButtonType="LinkButton" CommandName="Select"
Visible="False"></asp:ButtonColumn>
<asp:BoundColumn DataField="user_nm" HeaderText="Logon
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="last_nm" HeaderText="Last
Name"></asp:BoundColumn>
<asp:BoundColumn DataField="first_nm" HeaderText="First
Name"></asp:BoundColumn>
</Columns>
</asp:datagrid>

and setup an ItemDataBound event handler:

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, "");
}

Eliyahu

"UJ" <> wrote in message
news:...
> Is there any way to tell when a user clicks anywhere in a row? The only

way
> I can think to do it is to make each column a link with a button and use

the
> text as the value I want displayed.
>
> TIA.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
click click click Andy Morrison Computer Support 7 12-20-2007 06:50 AM
Need help creating a "Click absolutely ANYWHERE on this page" link for an HTML page with no content STILL LEARNING HTML 31 02-10-2007 09:53 PM
Click anywhere of DataGrid row to fire ButtonColumn event Hardy Wang ASP .Net 2 09-15-2006 01:42 PM
Highlight the row and click anywhere to select a row in a GridView Fernando Lopes ASP .Net 0 04-28-2005 12:24 PM
PC Anywhere setup Jim Wireless Networking 3 10-19-2004 02:46 PM



Advertisments