GridView templatefield textbox and AutoCompleteExtender ASP.NET - asp.net

I am having some issues using AJAX tool kit.
I am having a GridView with a template field, which has a textbox.
I have added an AutoCompleteExtender for this textbox. I have also set the ServicePath and ServiceMethod properties of the AutoCompleteExtender.
I wont get any error, but when i type text in the textbox, i wont get anything returned. I will post the code below.
Since i am a newbie to AJAX, i dont know if there is some other things which needs to be set for using AJAX in my project.
I am using ASP.NET and VB.NET for code-behind.
<%# Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Plain.Master" CodeBehind="BillPatient.aspx.vb" Inherits="Test.BillPatient" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="Content/themes/base/minified/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.10.3.min.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnCancel" EventName="Click" />
</Triggers>
<ContentTemplate>
<center>
<br />
<h1>
<asp:Label ID="lblTitle" runat="server" Text="New OP Patient Bill" />
</h1>
<br />
<asp:Label ID="lblStatus" runat="server" ForeColor="Green" />
<table id="tblModify" class="table" frame="border" width="100%">
<tr>
<td>
<asp:Label ID="lblBillDetail" runat="server" Text="Bill Detail(s)" Visible="false"></asp:Label>
<asp:GridView ID="gvBillDetail" runat="server" AllowPaging="True" AutoGenerateColumns="False" CssClass="table" Width="100%">
<Columns>
<asp:BoundField DataField="Id" HeaderText="ID">
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField HeaderText="Particulars">
<ItemTemplate>
<asp:TextBox ID="txtBillableItem" runat="server" Columns="30" MaxLength="30"></asp:TextBox>
<asp:AutoCompleteExtender ServiceMethod="GetCompletionList" MinimumPrefixLength="1" ID="txtBillableItem_AutoCompleteExtender" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="~/BillDetail.asmx" TargetControlID="txtPatientName">
</asp:AutoCompleteExtender>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Billable Amount">
<ItemTemplate>
<asp:Label ID="lblBillableAmount" runat="server"></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:ButtonField ButtonType="Button" CommandName="Modify" HeaderText="Modify" Text="Modify">
<ControlStyle CssClass="btn btn-info btn-xs" />
<HeaderStyle HorizontalAlign="Center" Width="90px" />
<ItemStyle HorizontalAlign="Center" />
</asp:ButtonField>
</Columns>
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
<asp:ValidationSummary ID="ValidationSummary2" runat="server" ForeColor="#993333" Style="text-align: center" Visible="True" ValidationGroup="AddBillDetail" />
<asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary" Text="Save" ValidationGroup="Save" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" CssClass="btn" Text="Cancel" />
</center>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Please forgive me for not formatting the code correctly :)
And my web service code is:-
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class BillDetail
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<System.Web.Services.WebMethodAttribute(),System.Web.Script.Services.ScriptMethodAttribute()>
Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
' Create array of movies
Dim movies() As String = {"Star Wars", "Star Trek", "Superman", "Memento", "Shrek", "Shrek II"}
' Return matching movies
Return (
From m In movies
Where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase)
Select m).Take(count).ToArray()
End Function
End Class
I hope the above information is sufficient. If not, please comment i will provide more info.
Thank you!

I got the solution for this myself.
I just stopped using WebService and put my ServiceMethod in my code-behind.
Set the property ServicePath to your own page. i.e If AutoCompleteExtender is in Test.aspx and the Service method is in Test.aspx.vb, then the properties will be:-
ServiceMethod="GetCompletionList"
and
ServicePath="~/Test.aspx.vb"
if the ServiceMethod is actually getting executed but if dropdown is not visible in U.I, then add the follwing code in head tag in html.
<style type="text/css" >
.popUpDialog
{
z-index: 99 !important;
}
.autoComplete_listMain
{
z-index: 2147483647 !important;
background: #ffffff;
border: solid 2px #808080;
color: #000000;
}
</style>
i dont know why i should add this , but it surely did work for me! :)
if anyone knows why, please be free to comment here....

Related

How to select an option from a dropdown list in one webform and view the result in a gridview in another webform?

this is my project, i am using visual studio 2010 and my coding language is vb. I am new to this and it will be safe to say that i don't know much of it yet.
I have a login page where the head of department enters his detail(employee number, employee name), selects his department and submits the information to see the result in other web form i.e all the employees that are under his department out of all the employees working for the company.
Because i don't know the code, i am getting all the employees of every department in the gridview instead of getting the employees for the department that was selected from the dropdown list.
here is my code for the first page
<%# Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="login" %>
<!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>
<style type="text/css">
.style1
{
width: 1179px;
height: 106px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<img alt="iocl" class="style1" src="Images/materials_hrd.bmp" /><br />
<br />
<br />
<br />
</div>
<asp:Label ID="Label1" runat="server" Text="Employee Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Employee_Number" runat="server" Text="Employee Number"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
-<br />
<asp:Label ID="Label2" runat="server" Text="Department"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Information Systems</asp:ListItem>
<asp:ListItem>Human Resources</asp:ListItem>
<asp:ListItem>Resource & Development</asp:ListItem>
<asp:ListItem>Finance</asp:ListItem>
<asp:ListItem>Pipelines</asp:ListItem>
<asp:ListItem>Marketing</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
</form>
</body>
</html>
And this is the second page's code
<%# Page Language="VB" AutoEventWireup="false" CodeFile="HODLogin.aspx.vb" Inherits="HODLogin" %>
<!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>
<style type="text/css">
.style1
{
width: 1259px;
height: 105px;
margin-top: 0px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<img alt="iocl" class="style1" src="Images/materials_hrd.bmp" /><br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None" Height="195px" ShowHeaderWhenEmpty="True"
Width="1125px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Employee Number" HeaderText="Employee Number"
SortExpression="Employee Number" />
<asp:BoundField DataField="Employee Name" HeaderText="Employee Name"
SortExpression="Employee Name" />
<asp:BoundField DataField="Department" HeaderText="Department"
SortExpression="Department" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString11 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString11.ProviderName %>"
SelectCommand="SELECT * FROM [employee database]"></asp:SqlDataSource>
<br />
<asp:Label ID="lblempno" runat="server"
Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Submit" />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Please tell me the process and the code and also where to put it, i am not very familiar with all this. Its kind of an emergency.
You can just store the selected item text in onw variable, like the below:
dim selText as string = DropDownList1.SelectedItem.Text
and on the click of submit button, perform your required tasks and then redirect page to another page along with the department name. Like the below code:
Response.Redirect("Page2.aspx?department=" + selText)
and on the second page i.e. Page2.aspx, just receive this value in query string, using below code.. wherever it is necessary either on page load or at your required place.
If Request.QueryString("department") <> Nothing Then
dim departmt as string = Request.QueryString("department")
End If
And use the above variable's value in your database query and get the related data to the department selected in the previous form.
I hope it will help you. :)
You can also save selected item text in Session. Afterward you can get this value from any page in your project:
Session("department") = DropDownList1.SelectedItem.Text
You also can use this value directly in your SqlDataSource on Page2:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString11 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString11.ProviderName %>"
SelectCommand="SELECT * FROM [employee database] WHERE Department LIKE #depart">
<SelectParameters>
<asp:SessionParameter DefaultValue="%" Name="depart" SessionField="user"
Type="string" />
</SelectParameters>
</asp:SqlDataSource>

Using UpdatePanel.Update() and having no result

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.

Display pop-up with simple text upon Button click

I have a button placed on each row of my GridView. When the user presses the button I would like to display a simple popup where I show text. Part of the text is the DataKeyName related to the specific row.
I already tried with ModalPopupExtender myMPE triggered by the button and I used a Panel myPanel as PopupControlID. The problem is that the TextBox txtPanel of the Panel where I place the DataKeyName value is always empty. I tried to debug without myMPE and the txtPanel of the Panel is correctly filled. I guess it makes a mess with the postbacks.
Anybody knows a solution?
Are you doing a manual refresh of the UpdaePanel on the modal popup panel ? If not, try manually refreshing the updatePanel & set its updateMode to Conditional.
Check above example
ASPX
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<link rel="Stylesheet" type="text/css" href="css/StyleSheet.css" />
<style type="text/css">
.modal
{
background-color: Aqua;
width: 150px;
height: 100px;
padding: 6px;
}
.modalBackground
{
background-color: #CCCCFF;
filter: alpha(opacity=40);
opacity: 0.5;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:UpdatePanel ID="upnGrid" runat="server">
<ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:GridView CssClass=".Grid-blue" ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="LinqDataSource1">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
<asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
<asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
<asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
<asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
<asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" OnClick="lbEdit_Click">Edit</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DataClassesDataContext"
EntityTypeName="" TableName="Products">
</asp:LinqDataSource>
</div>
<ajaxToolkit:ModalPopupExtender BackgroundCssClass="modalBackground" ID="mpeDetails"
CancelControlID="btnClosePopup" TargetControlID="btnShowModal" PopupControlID="pnlDetails"
runat="server">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnShowModal" runat="server" Text="Button" Style="display: none" />
<asp:Panel ID="pnlDetails" CssClass="modal" runat="server" Style="display: none">
<asp:UpdatePanel ID="upnDetails" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<label>
ID:</label><asp:TextBox ID="txtID" runat="server"></asp:TextBox>
<br />
<label>
Name:</label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<br />
</ContentTemplate>
</asp:UpdatePanel>
<div>
<asp:Button ID="btnClosePopup" runat="server" Text="Cancel" /></div>
</asp:Panel>
</form>
</body>
</html>
.CS
protected void lbEdit_Click(object sender, EventArgs e)
{
LinkButton lbTemp = (LinkButton)sender;
if (lbTemp != null)
{
GridViewRow grow =(GridViewRow) lbTemp.NamingContainer;
int id = Convert.ToInt32(GridView1.DataKeys[grow.RowIndex][0].ToString());
mpeDetails.Show();
txtID.Text = id.ToString();
upnDetails.Update();
}
}

MaintainScrollPositionOnPostback page directive not working with ajaxtoolkit control?

I getting issue with MaintainScrollPositionOnPostback with UpdataPanel in TestPage.aspx
page.
Page Header :
<%# Page Language="C#" MasterPageFile="~/MasterPages/Abc.master" AutoEventWireup="true"
MaintainScrollPositionOnPostback="true" CodeFile="Testpage.aspx.cs" Inherits="Testpage"
Title="Test Page" %>
I registered Ajaxtoolkit Control to my aspx page.
with
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
When I add " MaintainScrollPositionOnPostback="true" "page directive to my .aspx page
then I got the error message as shown in attached image.
Error: Status code returns from server:500
my Code
<asp:updatepanel id="upAnatomicalConfig" runat="server" updatemode="Conditional">
<ContentTemplate>
<div id="divform" style="width: 98%; text-align: left; margin: 0 auto" class="W_B">
<div>
<asp:validationsummary id="valsum" runat="server" validationgroup="abc" showmessagebox="true"
displaymode="BulletList" enableclientscript="true" showsummary="false" />
</div>
<!-- Here is some text box that I used for Save -------->
<asp:button id="btnSave" runat="server" text="Save" cssclass="button" causesvalidation="true"
validationgroup="abc" onclick="btnSave_Click" />
<asp:button id="btnCancel" runat="server" text="Cancel" cssclass="button" onclick="btnCancel_Click"
causesvalidation="false" />
<asp:datagrid id="dtgrid" runat="server" width="100%" cssclass="dgGrid" onitemdatabound="dtgrid_ItemDataBound"
cellpadding="2" autogeneratecolumns="false" showfooter="true" showheader="true"
onitemcreated="dtgrid_ItemCreated" allowpaging="True" pagesize="25" allowcustompaging="True"
gridlines="None" allowsorting="true" borderwidth="0px" borderstyle="None" onpageindexchanged="dtgrid_PageIndexChanged"
onsortcommand="dtgrid_OnSortCommand">
<Columns>
<asp:TemplateColumn HeaderStyle-Width="5%" ItemStyle-Width="5%">
<ItemTemplate>
<asp:ImageButton ID="ibtnEdit" CausesValidation="false" OnClick="ibtnEdit_Click"
runat="server" ImageUrl="~/Images/Edit.gif" ToolTip="Edit Template" CommandArgument='<%# Eval("tblID") %>'>
</asp:ImageButton>
<asp:ImageButton ID="ibtnDisc" CausesValidation="false" OnClick="ibtnDisc_Click"
runat="server" ImageUrl="~/Images/inactive_record.gif" ToolTip="Move to inactive"
CommandArgument='<%# Eval("tblID") %>'></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:updatepanel>
What is the reason behind that?
Page directive - "MaintainScrollPositionOnPostback" not worked
Reason is that 1) Framework 2.0 and 2) AjaxToolkit (ver 1.0.2....) Reset Position after AJAX (async call) postback not supported.

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