Monday, 26 December 2011

How to get the primary key value of the GridView rows in JavaScript or popup page?


.Aspx page
<asp:GridView ID="GridView1" runat="server" EnableViewState="false" DataKeyNames="AutoId">
<Columns>
<asp:TemplateField HeaderText="Details">
<ItemTemplate>
<a href="javascript:void(0)" title="Click for more details"
onclick="OpenPopup('<%# Eval("AutoId") %>')">Details</a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script language="javascript" type="text/javascript">
function OpenPopup(autoid) {
alert("AutoId: " + autoid);
window.open("dummyPage.aspx?autoid=" + autoid, "", "width=300,height=200");
}
</script>

No comments:

Post a Comment