listbox Problem

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
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
 
Last edited:
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
Code:
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.


Code:
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>
 
Back
Top