Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make entire row in datagrid clickable

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
GB
Hi

I'm using .net 1.1 and want to make an entire row in a datagrid clickable. The datagrid is in a usercontrol that is viewed when the tab is selected, when the user selects a record in the datagrid, I want it to update a few textboxes on another usercontrol that is hidden until the user selects the tab. I would like the user to be able to select anywhere on the row, rather than a given cell.

This is what I've got so far...

<HTML><asp:datagrid id="grd" runat="server" CellPadding="2" GridLines="None" AllowSorting="True" AutoGenerateColumns="False" Width="100%" ShowHeader="True">
<Columns>
<asp:BoundColumn Visible="False" DataField="P_ID" ReadOnly="True" HeaderText="P_ID"></asp:BoundColumn>
<asp:ButtonColumn DataTextField="Name" HeaderText="Name">
<HeaderStyle CssClass="CSShead"></HeaderStyle>
<ItemStyle Width="20%"></ItemStyle>
</asp:ButtonColumn>
</Columns>
</asp:datagrid>

<CODE>

Private Sub grd_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grd.ItemDataBound

e.Item.Attributes("onclick") = "javascript:alert(" + e.Item.ItemIndex.ToString + ")"

End Sub

Any help would be greatly appreciated

lbob
 
What you have shouldn't even compile. Try:

e.Items.Attribues.Add("onclick", "javascript:alert(" + e.Item.ItemIndex.ToString + ")")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top