Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Jay1b
Posted

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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...