Another question about a button in a datagrid.

B

Bart Schelkens

Sorry but I have another question about a button in a datagrid.

I have the following button in my datagrid :

asp:TemplateColumn HeaderText="">
<HeaderStyle width="20px"></HeaderStyle>
<ItemTemplate>
<asp:Button id="btnSubCategory" Text="Sub-Categorie" runat="server"
CommandArgument='<%# DataBinder.Eval(Container.DataItem,"CategoryID") %>'>
</asp:Button>
</ItemTemplate>
</asp:TemplateColumn>

This next part is to open a link whenever that button is clicked. The GetUrl
returns the URL of the page that needs to be opened.

Private Sub dtgCategories_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dtgCategories.ItemCommand
Dim lstrScript As New System.Text.StringBuilder()
With lstrScript
.Append("<script language=""javascript"">")
.Append("var NewWindow = window.open('" &
GetUrl(e.CommandArgument) & "')")
.Append("</script>")
End With
Page.RegisterStartupScript("SubCategory", lstrScript.ToString)
End Sub

It works fine, except for a small problem.
It opens the link in a new window. Apparently due to the line "var NewWindow
= window.open"
As my site is built-up of 3 frames, I would like to display that link into
my "mainFrame".
How can I do this?

Thx
 
S

Scott Allen

Hi Bart:

In the ItemCommand event you could do a Response.Redirect to the new
URL.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top