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">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="New Window"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server">Hyperlink</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>


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


Comments

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

Its an excellent article, to the point tutorial. Many thanks and great job.
http://www.dapfor.com/en/net-suite/net-grid/tutorial/real-time-blotter



  • 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:
    Email: