Today I am going to show you the use of the Ajax Model Popup Extander control and in this article I am going to explain how to update a record in a GridView using a modal popup extender.
Prerequisites
- Visual Studio 2005, 08, or 10
- SQL Server 2005, 08
- AjaxControlToolkit.dll
If you don't have ajaxcontroltoolkit then you can download it from here:
http://ajaxcontroltoolkit.codeplex.com/releases/view/90063
After downloading it install it via toolbox in Visual Studio; create a new tab in toolbox via right-click and add a new tab, rename it to ajax and then right-click on it and choose item and then browse to the location where you have downloaded the ajaxcontroltoolkit35.dll to and add it and click ok.
Save this connection string into you web.config file:
<connectionStrings>
<add name="HoneyConnectionString" connectionString="Data Source=adc-pc;Initial Catalog=honey;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<Ajax:ToolkitScriptManager ID="ToolkitScriptManager1"
runat="server"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataKeyNames="EmployeeID"
DataSourceID="SqlDataSource1"
onrowcommand="GridView1_RowCommand" BackColor="White"
BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" CellPadding="4" Width="550px">
<RowStyle BackColor="White" ForeColor="#330099" />
<Columns>
<asp:ButtonField Text="Edit" CommandName="OpenPopUp"/>
<asp:BoundField DataField="EmployeeID" HeaderText="ID"
InsertVisible="False" ReadOnly="True"
SortExpression="EmployeeID"/>
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName"/>
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName"/>
<asp:BoundField DataField="Country" HeaderText="Country"
SortExpression="Country"/>
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView>
<asp:Label ID="lblMessage" runat="server"/>
<asp:Button ID="btnPopUp" runat="server"
style="display:none" />
<Ajax:ModalPopupExtender ID="modalPopUpExtender1"
runat="server"
TargetControlID="btnPopUp"
PopupControlID="pnlModalPopUp"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancel"
X="20"
Y="100">
</Ajax:ModalPopupExtender>
<asp:Panel runat="Server" ID="pnlModalPopUp" BackColor="Azure"
BorderColor="Beige" BorderStyle="Inset">
<asp:GridView ID="EditGridView" runat="server"




Santosh YadavPosted Mar 16, 2013, 4:37 AM
very nice post.
tom linkerPosted Sep 11, 2012, 9:29 AM
This article really helpful for us. because it works without any database.
Swati AgarwalPosted Sep 11, 2012, 4:40 AM
good article,it helps me a lot..
Varshika JaineditedPosted Sep 11, 2012, 4:31 AMEdited Sep 11, 2012, 4:34 AM
If i want to delete the record then how can i do it.....