Jay1b Posted May 17, 2005 Posted May 17, 2005 (edited) Datagrid Problem Could someone please give me an idea how i can do the following please? ID Store Partnumber Quantity By clicking upon any of the rows (each one being a link), another screen will launch being passed the Unique ID of that row? I dont know if this is possible or not. Thanks Edited May 17, 2005 by Jay1b Quote
kahlua001 Posted May 18, 2005 Posted May 18, 2005 The whole row is a link? or just value(s) in each cell? Quote
Jay1b Posted May 18, 2005 Author Posted May 18, 2005 Either/or. Each value in each cell will launch the same piece of code/html Quote
kahlua001 Posted May 18, 2005 Posted May 18, 2005 Well, to do each value in a cell, then in your itemtemplate, have a hyperlink control so like <asp:Hyperlink id="lnkID" runat="server" /> Then in your itemdatabound event If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then Dim lnkID As Hyperlink = e.Item.FindControl("lnkID") lnkID.NavigateURL = "new_page.aspx?id=" & e.Item.DataItem("ID") lnkID.Target = "_blank" 'Do this for all other fields/links End If Now, since each field in the row is doing this, you could just add some javascript so that if the user clicks in any cell of the row, it will run the new window. If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then e.Item.Attributes.Add("onclick", "new_win('new_page.aspx?id=" & e.Item.DataItem("ID") & "')") End If Then add the javascript.. <Script language="javascript"> function new_win(url) { window.open(url,"",""); } </script> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.