Here in my form, i need to open a new window when i click the edit button in my grid view.also the corresponding ID value must be passed to the new window.I wrote the code for opening in a new window but it s not working.I searched and couldnt find how to send the selected record’s ID value to the new window.Help me how to do this.
<asp:GridView ID="gridUserDetails" runat="server" BackColor="White"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" AutoGenerateColumns="False" AllowSorting="true"
onselectedindexchanged="gridUserDetails_SelectedIndexChanged" onsorting="SortingGridData">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Employee Name" SortExpression="Name" />
<asp:BoundField DataField="Address" HeaderText="Employee Address" SortExpression="Address" />
<asp:BoundField DataField="Email" HeaderText="Employee Mail" SortExpression="Email"/>
<asp:BoundField DataField="Department" HeaderText="Department" SortExpression="Department"/>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnEdit" CausesValidation="false" runat="server" Text="Edit"
onClientClick="windowopen()"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#487575" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#275353" />
</asp:GridView>
This is the code for my Grid.And below is my javascript
<script language="javascript" type="text/javascript">
function windowopen() {
mywindow = window.open('ISSRegistrationForm.aspx', 'Employee Details', 'height=500, width=1100, status=no, resizable=no, scrollbars=yes, toolbar=no,location=no, menubar=no'
}
</script>
Create an anchor(a tag) inside a new TemplateField’s ItemTemplate:
and your JavaScript function should look like this: