Using UpdatePanel.Update() and having no result - asp.net

I have an aspx web page contains jquery mobile, I don't know why, whenever I call UpdatePanel.Update() in my code a white page appears as a result! of course the page is not empty because when I view source code (ctrl+u) all content are available. The strange point is for one call in a page, 2 ajax requests submit so two different responses received either two different post parameters. Post in first request is like this:
ScriptManager: UpdatePanel1|grdRequests$ctl03$btnCancel
__ASYNCPOST: true
__EVENTARGUMENT: nothing
__EVENTTARGET: nothing
__EVENTVALIDATION: value here
__LASTFOCUS: nothing
__VIEWSTATE value here
and response is like this:
1|#| |4|5451|updatePanel|UpdatePanel1|
but in second request there is no ScriptManager and ASYNCPOST parameteres, also in response only old content could see no more data. any idea?
CLIENT SIDE:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ConfOne.aspx.cs" Inherits="ConfDC"%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="jquery.mobile-1.1.1.min.css" />
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="jquery.mobile-1.1.1.min.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server" dir="rtl" defaultbutton="btnpage" name="form1">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode = "Conditional">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Button runat="server" ID="btnpage" Width="1px" Height="1px" Visible="false"/>
<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
</td>
</tr>
</table>
<div id="mcnt">
<div data-role="page">
<div data-role="content" style="padding: 10px; text-align: center;">
<asp:GridView ID="tbls runat="server" AutoGenerateColumns="False" Width="100%"
CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt"
CellPadding="1" CellSpacing="1" AllowPaging="True" DataKeyNames="Id" OnRowCommand="tbls_RowCommand"
OnPageIndexChanging="tbls_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# Bind("Amount") %>'></asp:Label>
</ItemTemplate>
<ItemStyle/>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Decline" ID="btnCancel" CommandName="CancelRequest" runat="server"
CommandArgument='<%# DataBinder.Eval(Container, "DataItem.id") %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Accept" ID="btnConfirm" CommandName="ConfirmRequest" runat="server"
OnClientClick="return confirm('Are you sure?');"
CommandArgument='<%# DataBinder.Eval(Container, "DataItem.id") %>' />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="pgr"></PagerStyle>
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
</asp:GridView>
</div>
<div id="rsnCnt">
<asp:Panel ID="pnlReasons" Width="100%" runat="server" Visible="false">
<fieldset>
<asp:TextBox runat="server" ID="txtReasons" CssClass="TextArea" Height="70px" Width="100%"
TextMode="MultiLine"></asp:TextBox>
<asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
<div id="btnActionCnt">
<div style="float:right;">
<asp:Button type="button" runat="server" ID="btnCancelRequest" Width="100px" class="groovybutton2"
Text="OK " OnClientClick="return confirm('are you sure?');" />
</div>
<div style="float:left;">
<asp:Button type="button" runat="server" ID="btnCancel" class="groovybutton2" Text="NOT OK"
onmouseover="" onmouseout=""
OnClick="btnCancel_Click" Height="25px" Width="100px" />
</div>
</div>
</fieldset>
</asp:Panel>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
SERVER SIDE:
protected void tbls_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "CancelRequest")
{
pnlReasons.Visible = true;
UpdatePanel1.Update();
}
}

Where are you binding your gridview..
You need to bind that in
private void Page_Load()
{
if (!IsPostBack)
{
// Need to Bind your grid here
}
}

I dont know why but when I removed updatepanel works ok.

Related

page style get disturbed on ModalPopupExtender on click of button in a gridview in Update panel

I have a multiple records in a Grid view inside an update panel, Grid-view has ImageButton , onclick of this button I am displaying a ModalPopupExtender to display details of selected row. Then I close the dialog using close button.
Everything works fine until I open and close the modelpopup 10 times , after that page styles gets disturbed and page start looking ugly. When I remove the update panel then everything works fine but I need update panel for smooth UI experience.
My code is below, please help me as soon as possible , I am stuck because of this. temporarily , I am handling this by dopostback on 10th time so that user doesn't experience refresh everytime.
aspx code.
<asp:UpdatePanel ID="udpDocuments" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="Content">
<h1 class="HomePageHeading">Standard Operating Procedures, Guidelines, and Policies</h1>
<div class="ClearFix MarginBottom30">
<div class="SeriesInformation">
<h2>Series</h2>
<ol class="ValueList">
<li>1.000 - <span>Personnel Procedures</span>
</li>
<li>2.000 - <span>Veterinary Care/Laboratory Animal Medicine</span>
</li>
<li>3.000 - <span>Animal Husbandry/Facility Operations</span>
</li>
<li>4.000 - <span>Safety</span>
</li>
<li>5.000 - <span>Technical Procedures</span>
</li>
<li>6.000 - <span>Administration</span>
</li>
</ol>
</div>
<div class="PolicyNumberAbbr">
<h2>SOP/Policy Number Abbreviations</h2>
<ol class="ValueList">
<li>P = <span>Policy</span>
</li>
<li>G = <span>Guidelines</span>
</li>
<li>B = <span>Bethesda</span>
</li>
<li>F = <span>Frederick</span>
</li>
</ol>
</div>
</div>
<asp:Panel ID="SearchCriteria" runat="server" DefaultButton="btnSearch">
<div class="FilterWrap" style="clear: both;">
<fieldset class="FnlFieldSet">
<legend class="Clip">Filter SOP Listings</legend>
<ol class="InputFields">
<li>
<asp:Label Text="Filter by:" runat="server" ID="lblSortOrder" AssociatedControlID="ddlSortCriteria" />
<ol class="HorizontalInput">
<li>
<asp:DropDownList ID="ddlSortCriteria" runat="server" SelectMethod="Load_Filter"
OnSelectedIndexChanged="ddlSortCriteria_SelectedIndexChanged" AutoPostBack="true"
AppendDataBoundItems="true" DataTextField="Value" DataValueField="Key">
</asp:DropDownList>
<asp:DropDownList ID="ddlCampus" Visible="false" runat="server" SelectMethod="Load_Campus" AppendDataBoundItems="true" DataTextField="value" DataValueField="key">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<asp:DropDownList ID="ddlSeries" Visible="false" runat="server" SelectMethod="Load_Series" AppendDataBoundItems="true" DataTextField="Name" DataValueField="Id">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<dms:WatermarkTextBox ID="wmTitle" runat="server" MaxLength="60" Columns="30" WatermarkText="Title" />
</li>
<li>
<span class="InputButtonWrapper HasIcon SearchIcon">
<asp:Button ID="btnSearch" Text="Search" OnClick="btnSearch_Click" runat="server" />
</span>
<asp:Button ID="btnReset" Text="Reset" OnClick="btnReset_Click" runat="server" />
</li>
</ol>
</li>
</ol>
</fieldset>
</div>
</asp:Panel>
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.MainFileAttachment==null?string.Empty:Item.MainFileAttachment.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.Title %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Number" SortExpression="RevisionNumber">
<ItemTemplate>
<asp:Label ID="lblRevisionNumber" runat="server" Text='<%# Item.RevisionNumber %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Date" SortExpression="RevisionDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.RevisionDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Effective Date" SortExpression="EffectiveDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.EffectiveDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Campus" SortExpression="LocationId">
<ItemTemplate>
<%# Dms.Framework.Extensions.EnumExtensions.Description(Item.LocationId) %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
<div>
<%-- OnCancelScript="__doPostBack('Ok','')" is added to fix the issue when you open the model popup 10 times and on 11th time it mashed up the UI--%>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
OnCancelScript="OnCloseButtonClientClick()"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</div>
</div>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="closeCount" ClientIDMode="Static" Value="0" runat="server" />
<script type="text/javascript">
var count = 0;
function OnCloseButtonClientClick() {
if (count == 8) {
//__doPostBack('Ok', '');
count = 0;
}
else {
count = count + 1;
}
return false;
}
</script>
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
mpeAttachments.Show();
}
}
Got solution, It is only about moving code around update panel:
ASPX code:
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:UpdatePanel ID="upAttachmentList" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Panel>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
ASPX.cs: code:
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
upAttachmentList.Update();
mpeAttachments.Show();
}
}

Ajax updateProgress does not show progress for the right UpdatePannel

I have an Ajax panel first panel inside another panel second panel and an updateProgress linked to the first panel
With this I have two problems:
The updateProgress show the progress image when the second panel updates but not when the first panel updates
To update the 2nd panel I have to press the button inside the second panel twice
<asp:UpdateProgress ID="UProc_TabContainer" runat="server" AssociatedUpdatePanelID="UP_FirstPanel"
DisplayAfter="1">
<ProgressTemplate>
<div id="dvProgress" runat="server" style="position: absolute; top: 300px; left: 450px;
text-align: center;">
<asp:Image ID="wait" runat="server" ImageUrl="~/Images/wait3.gif" Height="120px"
Width="128px" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UP_FirstPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<script language="javascript" type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "block"; img.src = "Images/Icons/minus.jpg";
} else { div.style.display = "none"; img.src = "Images/Icons/plus.jpg"; }
}</script>
<asp:DropDownList ID="DateSelection" runat="server" AutoPostBack="True" Height="21px"
Width="134px">
</asp:DropDownList>
<asp:GridView ID="GV_SL" runat="server" OnRowDataBound="gvUserInfo_RowDataBound"
OnRowCommand="GV_SL_RowCommand" AutoGenerateColumns="false" DataSourceID="SQL_Weekly">
<Columns>
<asp:TemplateField ItemStyle-Width="50px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("name") %>');">
<img id="imgdiv<%# Eval("name") %>" width="15px" border="0" src="Images/Icons/plus.jpg" /></a></ItemTemplate>
<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Group" SortExpression="name" />
<asp:BoundField DataField="ASL" HeaderText="SL% Act" ReadOnly="True" SortExpression="ASL" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("name") %>" style="display: none; position: relative; left: 15px;
overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Metric" HeaderText=" " HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Actual" HeaderText="Actual" HeaderStyle-HorizontalAlign="Left" />
</Columns>
</asp:GridView>
<br />
<asp:UpdatePanel ID="UP_SecondPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<%-- --%>
<asp:TextBox ID="TB_Comments" runat="server" Text="Example: Text will be entered here"
TextMode="MultiLine" Rows="4" Width="510px"></asp:TextBox>
<asp:Button ID="B_Save" runat="server" CommandName="AddText" CommandArgument="<%# CType(Container,GridViewRow).RowIndex %>"
Text="Save Changes" />
</ContentTemplate>
</asp:UpdatePanel>
<%-- --%>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DateSelection" EventName="SelectedIndexChanged" />
</Triggers>
Any ideas on what I'm doing wrong?
Thanks
I have resolved the 1st problem presented by removing AssociatedUpdatePanelID="UP_FirstPanel" from the UpdateProgress. I hope it helps someone
I've created a separate posting with further detail and simplified code for the second problem (Nested Ajax UpdatePanel in Gridview needs button control to be clicked twice)

how to select last page on a radlistview datapager

I have a radlistview which has the datapager enabled...
But when I launch the website it currently loads the first datapage on the listview (i.e the first page of comments). Is there a way to change this so that it opens the last page?
Here is the current radlistview...
<telerik:RadListView ID="RadListViewComments" runat="server" AllowPaging="True" DataKeyNames="ID" DataSourceID="SqlDataSourceComments" PageSize="5">
<LayoutTemplate>
<div class="RadListView RadListViewFloated RadListView_Default">
<div class="rlvFloated rlvAutoScroll">
<div id="itemPlaceholder" runat="server">
</div>
</div>
<telerik:RadDataPager ID="RadDataPager1" runat="server">
<Fields>
<telerik:RadDataPagerButtonField FieldType="Numeric" />
</Fields>
</telerik:RadDataPager>
</div>
<ItemTemplate>
<div class="rlvI" style="width: 700px; margin-bottom: 50px" margin-right: 100%>
<asp:Label ID="ownerLabel" runat="server" Text='<%# Eval("owner") %>' /> &nbsp - &nbsp
<asp:Label ID="dateLabel" runat="server" Text='<%# Eval("commentdate")%>' />
<br />
<asp:Label ID="commentLabel" runat="server" Text='<%# Eval("comment") %>' />
</div>
</ItemTemplate>
<EmptyDataTemplate>
<div class="RadListView RadListView_Default">
<div class="rlvEmpty">
There are no previous comments.</div>
</div>
</EmptyDataTemplate>
</telerik:RadListView>
Thanks
In the code-behind you can fire a command event with the "Last" argument on PageLoad to force it to go to the last page.
See
how change the RadDataPager Page# From CodeBehind (server-side)
http://www.telerik.com/help/aspnet-ajax/datapager-overview.html

Button Outside Gridview not firing once click on Edit button of gridview

I have a gridview and i have two buttons edit and delete.Once i click on edit button, i take the values and put those in textboxes outside grid and visible update and cancel button. but that does not fires..
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnladdproduct" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label11" runat="server" AssociatedControlID="btnAddProduct"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnAddProduct" ValidationGroup="grpProduct" runat="server" CssClass="mws-button red" Text="Add" OnClick="btnAddProduct_Click" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlUpdateProduct" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label12" runat="server" AssociatedControlID="btnUpdateProduct"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnUpdateProduct" runat="server" CausesValidation="False" CssClass="mws-button blue" Text="Update" OnClick="btnUpdateProduct_Click" />
</div>
</div>
</asp:Panel>
<asp:Panel ID="pnlCancel" runat="server">
<div class="mws-form-col-1-8">
<asp:Label ID="Label13" runat="server" AssociatedControlID="btnCancelUpdate"> </asp:Label>
<div class="mws-form-item large">
<asp:Button ID="btnCancelUpdate" CausesValidation="False" runat="server" CssClass="mws-button gray" Text="Cancel" OnClick="btnCancelUpdate_Click" />
</div>
</div>
</asp:Panel>
<div class="mws-form-col-8-8">
<asp:GridView ID="grdProduct" ShowHeaderWhenEmpty="True" CssClass="mGrid" runat="server" AutoGenerateColumns="False" AllowPaging="True" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" OnPageIndexChanging="grdProduct_PageIndexChanging" OnRowDeleting="grdProduct_RowDeleting" OnRowEditing="grdProduct_RowEditing">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Product" SortExpression="Product" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Rate" HeaderText="Rate" SortExpression="Rate" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:ButtonField ButtonType="Image" CommandName="Edit" HeaderText="Edit" ImageUrl="~/css/icons/16/edit.png" ShowHeader="True" Text="Edit" />
<asp:ButtonField ButtonType="Image" CommandName="Delete" HeaderText="Delete" ImageUrl="~/css/icons/16/delete.png" ShowHeader="True" Text="Delete" />
<asp:TemplateField HeaderText="HiddenColumn">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdfProductID" runat="server" Value='<%# Bind("ProID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No Products Added !!
</EmptyDataTemplate>
</asp:GridView>
<div class="mws-form-row inline">
<asp:Label ID="Label15" runat="server" AssociatedControlID="txtQuantity">Total Amount</asp:Label>
<div class="mws-form-item medium">
<asp:TextBox ID="txtTotalAmount" BackColor="Beige" BorderColor="red" ReadOnly="True" CssClass="mws-textinput" runat="server"></asp:TextBox>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdateProduct" EventName="Click"/>
<asp:PostBackTrigger ControlID="btnCancelUpdate" />
</Triggers>
</asp:UpdatePanel>
Server side Code..
protected void grdProduct_RowEditing(object sender, GridViewEditEventArgs e)
{
Session["proID"] = StepGetHiddenValuesFromGridControl(e.NewEditIndex);
txtQuantity.Text = grdProduct.Rows[e.NewEditIndex].Cells[1].Text;
txtRate.Text = grdProduct.Rows[e.NewEditIndex].Cells[2].Text;
txtAmount.Text = grdProduct.Rows[e.NewEditIndex].Cells[3].Text;
txtQuantity.BackColor = Color.Beige;
txtRate.BackColor = Color.Beige;
txtAmount.BackColor = Color.Beige;
//pnladdproduct.Visible = false;
//pnlUpdateProduct.Visible = true;
//pnlCancel.Visible = true;
}
protected void btnUpdateProduct_Click(object sender, EventArgs e)
{
// this code not firing
}
I don't think there's a need for triggers.

How to value set on TextBox

Work on Asp.Net C# VS08.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var styleToSelect;
function onOk() {
document.getElementById('GridView1').className = styleToSelect;
}
</script>
<script language="javascript" type="text/javascript">
function GetRowValue(val) {
// alert(val);
document.getElementById("Text1").value = val;
// hardcoded value used to minimize the code.
// ControlID can instead be passed as query string to the popup window
//window.opener.document.getElementById("ctl00_ContentPlaceHolder2_GridView1_txtCOM_NAME").value = val;
//window.opener.document.getElementById('%=txtCOM_NAME.ClientId%>').value = val;
//window.opener.document.getElementById("txtParent").value = val;
//Text1.innerHTML=val;
// alert(val);
// window.close();
}
function Hello()
{
document.getElementById("Text1").value="2";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:LinkButton ID="LinkButton1" runat="server">Please click to select an alternate text style.</asp:LinkButton><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
ReadOnly="True" SortExpression="CategoryID" />
<asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="Button2"
PopupControlID="Panel2"
BackgroundCssClass="modalBackground"
DropShadow="true"
OkControlID="OkButton"
CancelControlID="CancelButton"
OnOkScript="onOk()"
/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px" CssClass="modalPopup">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" OnRowDataBound="GridView2_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="ckb">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server"></asp:Label>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
ReadOnly="True" SortExpression="CategoryID" />
<asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:TemplateField>
<AlternatingItemTemplate>
<asp:Button ID="btnSelect" runat="server" Text="Select" />
</AlternatingItemTemplate>
<ItemTemplate>
<asp:Button ID="btnSelect" runat="server" Text="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:Button ID="Button3" runat="server" Text="Button" />
<div align="center">
<asp:Button ID="OkButton" runat="server" Text="OK" OnClick="OkButton_Click" OnClientClick=Hello() />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
<input id="Button4" type="button" value="button" /></div>
</asp:Panel>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
After Popup .Want to select a row on popup grid then click on ok button and put the value on TextBox fo the parent grid.How to set value on Parent Grid.
I guess you should use the row command event handler of the grid, if I got you right:
OnRowCommand="RowCommand"
Then you can add a button to the grid:
<asp:LinkButton ID="LnkButton" runat="server" CommandName="setValue" CommandArgument='<%# Eval("id")%>'>Set value</asp:LinkButton>
And a method to handle it:
protected void RowCommand(Object sender, GridViewCommandEventArgs e)
if (e.CommandName=="setValue")
[do something with e.CommandArgument and close dialog]

Resources