Open new Window using DataGrid C#

Following code will create a label in HeaderTemplate and a Hyperlink in ItemTeplate. By clicking on dat link a new window can be open. But as datagrid will shown only when it has data so hyperlink can be used to shown some data from db.

<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="false" Width="100%" OnItemCommand="DataGrid1_ItemCommand1" OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged1" Height="181px">
<asp:Label ID="Label1" runat="server" Text="New Window"></asp:Label>
<asp:HyperLink ID="HyperLink1" runat="server">Hyperlink</asp:HyperLink>

Follwing script code should be shown under Head Tag.
<script type="text/javascript">
function fun()
var detailsWindow;,"dfd","width=400,height=350, menubar,resizable ");
return false;


Author: messyleon08 Oct 2012 Member Level: Bronze   Points : 0

Its an excellent article, to the point tutorial. Many thanks and great job.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: