TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sreekanth v
NA
51
0
Gridview update using usercontrol
Jan 7 2012 9:40 AM
when i click on update using edit button in gridview. usercontrol is not getting popup here is my code.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="GridUser.aspx.cs" Inherits="aspprojects2.Gridview.GridUser" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Src="~/usercontrol/LocationUser.ascx" TagName="usercontrol" TagPrefix="uc1"%>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="scm" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="false" DataKeyNames="locationid">
<Columns>
<asp:TemplateField HeaderText="LocationId">
<ItemTemplate>
<asp:Label ID="lbllocationid" runat="server" Text='<%# Eval("locationid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Regionalgroup">
<ItemTemplate>
<%# Eval("regionalgroup") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtregionalgroup" runat="server" Text='<%# Eval("regionalgroup") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkedit" runat="server" Text="Edit" OnClick="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:LinkButton ID="lnkfake" runat="server"></asp:LinkButton>
<uc1:usercontrol id="uc" runat="server" EnableViewState="false" style="display:none">
</uc1:usercontrol>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="uc"
TargetControlID="lnkfake" BackgroundCssClass="modalBackground"
DropShadow="false">
</asp:ModalPopupExtender>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gv" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BO;
namespace aspprojects2.Gridview
{
public partial class GridUser : System.Web.UI.Page
{
Employees emp = new Employees();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
FillLocations();
}
protected void FillLocations()
{
gv.DataSource = emp.GetLocations();
gv.DataBind();
}
protected void Edit(object sender, EventArgs e)
{
LinkButton lnk = sender as LinkButton;
GridViewRow row = (GridViewRow)lnk.NamingContainer;
uc.locationid = Convert.ToInt32( gv.DataKeys[row.RowIndex].Value.ToString());
uc.regionalgroup = row.Cells[1].ToString();
ModalPopupExtender1.Show();
}
}
}
.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LocationUser.ascx.cs" Inherits="aspprojects2.LocationUser" %>
<asp:UpdatePanel ID="up2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnl" runat="server" CssClass="modalPopup" >
<table>
<tr>
<td>
<asp:Label ID="lbllocationid" runat="server" Text="LocationId"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtlocationid" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblregionalgroup" runat="server" Text="RegionalGroup"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtregionalgroup" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnsave" runat="server" Text="Save" onclick="btnsave_Click" />
</td>
<td>
<asp:Button ID="btncancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BO;
namespace aspprojects2
{
public partial class LocationUser : System.Web.UI.UserControl
{
private int _locatonid = 0;
private string _regionalgroup = string.Empty;
#region properties
public int locationid
{
get { return _locatonid; }
set { _locatonid = value; }
}
public string regionalgroup
{
get { return _regionalgroup; }
set { _regionalgroup = value; }
}
#endregion properties
Employees emp = new Employees();
Location lo = new Location();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
txtlocationid.Text = locationid.ToString();
txtregionalgroup.Text = regionalgroup;
}
protected void btnsave_Click(object sender, EventArgs e)
{
lo.locationid = Convert.ToInt32(txtlocationid.Text);
lo.regionalgroup = txtregionalgroup.Text;
emp.updatelocation(lo);
}
}
}
i am getting error like this.
Microsoft JScript runtime error: 'this._foregroundElement.parentNode' is null or not an object
Reply
Answers (
0
)
Showing image in pop up
Define LeaseTime, SponsorshipTime in ASP.NET