Showing posts with label paging. Show all posts
Showing posts with label paging. Show all posts

Saturday, March 24, 2012

Paging a GridView with CSS Friendly Adapters causes a total postback with AJAX Beta1

Hello,

I have upgraded an existing project (Atlas CTP) to the Atlas Beta1 and encountered a problem with a GridView inside an UpdatePanel. I am using theCSS Friendly ASP.NET 2.0 Control Adapters for the GridView and paging the results causes a total postback instead of partial. Here's my code:

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> private System.Collections.Generic.List<string> GetList() { System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(); for (int i = 0; i < 100; i++) { list.Add("item " + i.ToString()); } return list; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ResultsGrid.DataSource = GetList(); ResultsGrid.DataBind(); } } protected void ResultsGrid_PageIndexChanging(object sender, GridViewPageEventArgs e) { ResultsGrid.PageIndex = e.NewPageIndex; ResultsGrid.DataSource = GetList(); ResultsGrid.DataBind(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel ID="Updaty" runat="server"> <ContentTemplate> <asp:GridView id="ResultsGrid" runat="server" PageSize="10" AllowPaging="true" OnPageIndexChanging="ResultsGrid_PageIndexChanging" /> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>

Using the Atlas CTP the same code caused a partial postback when paging the GridView. Any ideas?

Regards,
Darin

One way around this is to add a trigger to the UpdatePanel for the PageIndexChanging event.

<Triggers>
<asp:AsyncPostBackTrigger ControlID="ResultsGrid" EventName="PageIndexChanging" />
</Triggers>

I tried this and it seem to then update the panel incrementally as expected.


I posted a fix here...http://forums.asp.net/thread/1442598.aspx

Paging a GridView in an UpdatePanel

Has anyone been able to implement paging for a GridView inside an UpdatePanel?

I get a JavaScript error everytime I click on the page number: "Object Required".

Enclosing the GridView control inside an UpdatePanel worked fine for me, including the paging.

Have you tried stepping through your code with VisualStudio? This works really good for me when debugging atlas. Also if your gridview is bound to a SqlDataSource you can enable PagingAndSortingCallbacks, and that has the same effect.


hello.

can you show us your code?

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<atlas:UpdatePanelID="EmpOrders"runat="server"Mode="Conditional">

<Triggers><atlas:ControlEventTriggerControlID="Button1"EventName="Click"/></Triggers>

<ContentTemplate>

<asp:ButtonID="Button1"runat="server"Font-Italic="True"OnClick="Button1_Click1"Text="Search"/><br/>

<asp:GridViewID="GridView1"runat="server"CellPadding="4"ForeColor="#333333"GridLines="None"PageSize="15"AllowPaging="True"AutoGenerateColumns="False"OnPageIndexChanging="GridView1_PageIndexChanging"AllowSorting="True">

<Columns>

<asp:BoundFieldDataField="ShipName"HeaderText="Ship Name"SortExpression="ShipName"/>

<asp:BoundFieldDataField="ShipCountry"HeaderText="Country"SortExpression="Country"/>

<asp:BoundFieldDataField="Freight"HeaderText="Freight"SortExpression="Freight"/>

</Columns>

</asp:GridView>

</ContentTemplate>

</atlas:UpdatePanel>

Codebehind:

protectedvoid GridView1_PageIndexChanging(object sender,GridViewPageEventArgs e)

{

GridView1.PageIndex = e.NewPageIndex;

BindGrid();

}


hello.

well, it looks ok to me.

there's one thing i don't understand: you've added a trigger to the panel and configured it against a button which is also placed inside the panel...

i've built a small page that is working ok here (i've built a struct to simulate the info that is passed as source of the grid). see if it works with your current configuration:

public struct Ship
{
private string _shipName;

public string ShipName
{
get { return _shipName; }
set { _shipName = value; }
}
private string _shipCountry;

public string ShipCountry
{
get { return _shipCountry; }
set { _shipCountry = value; }
}
private string _freight;

public string Freight
{
get { return _freight; }
set { _freight = value; }
}

public Ship( string shipName, string shipCountry, string freight )
{
_shipName = shipName;
_shipCountry = shipCountry;
_freight = freight;
}
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!this.IsPostBack )
{
BindGrid();
}
}

void BindGrid()
{
Ship [] shippes = new Ship[]{
new Ship( "1","1","1" ),
new Ship( "2","2","2" ),
new Ship( "3","3","3" )
};

GridView1.DataSource = shippes;
GridView1.DataBind();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

GridView1.PageIndex = e.NewPageIndex;

BindGrid();

}

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
<atlas:UpdatePanel ID="EmpOrders" runat="server" Mode="Conditional">
<Triggers>
<atlas:ControlEventTrigger ControlID="Button1" EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Font-Italic="True" Text="Search"/><br/>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" PageSize="2" AllowPaging="True"
AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True">
<Columns>
<asp:BoundField DataField="ShipName" HeaderText="Ship Name" SortExpression="ShipName"/>
<asp:BoundField DataField="ShipCountry" HeaderText="Country" SortExpression="Country"/>
<asp:BoundField DataField="Freight" HeaderText="Freight" SortExpression="Freight"/>
</Columns>
</asp:GridView>
</ContentTemplate>
</atlas:UpdatePanel>
<%= DateTime.Now.ToString() %>
</form>
</body>
</html>

Are you doing custom paging? I'm asking because normally, the GridView control takes care of this automatically (as well the binding -- unlike in DataGrid) so that you don't even have to handle the event. This is assuming that your datasource can handle paging (DataSet does I believe).


hello guys, and yes, i think that he is using the asp.net 1.X binding instead of using the new data source controls...

Yes I′m handling the binding as with .NET v1.x


hello again.

Can you run the sample page i've presented in a previous post?

Luis, your example works fine. The only difference between your code and mine is that you use a Struct as your datagrid's datasource and I use a DataSet.

What do you think?


hello.

well, i think that using a dataset shouldn't make any difference. can you build a sample page that uses a dummy dataset to reproduce the problem and post it here?
I have the same problem using an SQLDatasource. Is it possible that it only work with dataset because with dataset you can generate XML. Maybe with SqlDatasource it doesn't generate Xml so Atlas on gridview with SqlDatasource will no work ?
Luis, I′m working on the dummy page. In the meantime, I noticed that having

EnablePartialRendering="true"

won't let me fire the paging, deleting etc. events

Do you have it set to true?


hello.

yes i have. i've introduced < in my previous post and i think that now you should be able to see everything.

Paging and Sorting Problem with ASP.net AJAX

Hi,
I have created 3 level hierarchial grid using datagrid control ofasp.net andasp.net ajax v1.0.

In this I have implemented custom paging with datareaders.

If my second level grid contains only one record, my thirdlevel grid paging and sorting works fine.But if my second level grid contains more than one record, my third level grid paging and sorting stops functioning

Similarly if my first level grid contains one record, paging and sorting of records in second level grid works fine. If it contains more than one record, paging and sorting of records in second level grid stops functioning.

Without AJAX, the code is working perfectly.
Can anybody out here, figure out what is the problem and help me in fixing this issue.

Thanks in Advance

Anu

share us your code please!

Hi,

Please have my source code of it,I have connection string in web.config.I am sending you the aspx page and aspx.vb(code behind page)

This is my aspx Page

-----------

<%@. Page Language="VB" MaintainScrollPositionOnPostback="true" AutoEventWireup="false" CodeFile="HierGrid.aspx.vb" Inherits="HierGrid" %>

<%@. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>

<!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>Contract Customer List</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="http://links.10026.com/?link=Includes/Style Sheet/hcms_jnj.css" rel="stylesheet" type="text/css">
</head>
<body>
<form id="form1" runat="server">

<table width="100%" border="0" align="center" cellspacing="0" cellpadding="0" height="32">

<tr>
<td height="34" align="center" valign="middle" class="pagetitle" width="852">
<u>Contract - Customer List</u></td>
</tr>
</table>

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<DIV>
<asp:UpdatePanel ID="dgParentPanel" runat="server" UpdateMode=always>
<ContentTemplate>
<asp:DataGrid ID="dgParent" runat="server" CssClass ="grid_body" AllowCustomPaging="True" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" PageSize="10" PagerStyle-Mode="NumericPages" Width="836px">
<ItemStyle CssClass="grid_body"></ItemStyle>
<HeaderStyle CssClass="grid_header"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton ID="imgBtnParent" ImageUrl="~/Images/plus.gif" CommandName="Expand" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="CONTR_ID" SortExpression="CONTR_ID" HeaderText="Contract ID">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="120px" />
<HeaderStyle Width="130px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:BoundColumn DataField="CONTR_NO" SortExpression="CONTR_NO" HeaderText="Contract Number">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="120px" />
<HeaderStyle Width="120px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:BoundColumn DataField="CONTR_NM" SortExpression="CONTR_NM" HeaderText="Contract Name">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="250px" />
<HeaderStyle Width="250px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:BoundColumn DataField="CONTR_ADDR" SortExpression="CONTR_ADDR" HeaderText="Address">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="250px" />
<HeaderStyle Width="250px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:BoundColumn DataField="EFFTV_STRT_DT" SortExpression="EFFTV_STRT_DT" HeaderText="Effective Start Date">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="10px" />
<HeaderStyle Width="100px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:BoundColumn DataField="EFFTV_END_DT" SortExpression="EFFTV_END_DT" HeaderText="Effective End Date">
<ItemStyle HorizontalAlign="Left" BorderStyle =Solid BorderColor="White" Width="10px" />
<HeaderStyle Width="100px" ForeColor="Blue" />
</asp:BoundColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:UpdatePanel ID="dgChild1Panel" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:PlaceHolder ID="phParent" Visible="false" runat="server" >
</td></tr>
<tr><td colspan="7">
<asp:DataGrid ID="dgChild1" OnPageIndexChanged = "dgChild1_PageIndexChanged" OnSortCommand= "dgChild1_SortCommand" FooterStyle-CssClass ="grid_body" AllowPaging ="true" AllowCustomPaging = "true" BorderStyle = "Solid" BorderWidth="1px" BorderColor ="white" FooterStyle-Height="1px" PagerStyle-Mode="NumericPages" Width="1200px" AllowSorting="True" OnItemCommand = "dgChild1_ItemCommand" CssClass ="grid_body" ShowFooter="True" AutoGenerateColumns="false" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<ItemStyle CssClass="grid_body" ></ItemStyle>
<HeaderStyle CssClass="grid_header" BorderStyle =Solid BorderColor =white ></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton BorderStyle =Solid BorderColor =white ID="imgBtnChild" CommandName="ExpChild1" ImageUrl="~/Images/plus.gif" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible=false ItemStyle-BorderColor =white ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "" DataField="parnt_intract_no" SortExpression="parnt_intract_no" HeaderText="parnt_intract_no" HeaderStyle-ForeColor ="Blue" ></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "100px" DataField="INTRACT_NO" SortExpression="INTRACT_NO" HeaderText="Interact Number" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "200px" DataField="CUST_NM" SortExpression="CUST_NM" HeaderText="Customer Name" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "200px" DataField="CUST_ADDR" SortExpression="CUST_ADDR" HeaderText="Customer Address" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="Relshp_strt_dt" SortExpression="Relshp_strt_dt" HeaderText="Contract Relationship Eff. Date" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="Relshp_end_dt" SortExpression="Relshp_end_dt" HeaderText="Contract Relationship Exp. Date" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="intract_cot_cd" SortExpression="intract_cot_cd" HeaderText="COT Code" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="cust_typ" SortExpression="cust_typ" HeaderText="Customer Type" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="DDD_NO" SortExpression="DDD_NO" HeaderText="DDD Number" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="DEA_NO" SortExpression="DEA_NO" HeaderText="DEA Number" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="PHS_ELGBLT" SortExpression="PHS_ELGBLT" HeaderText="PHS Eligible" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "80px" DataField="NCI_ACCT" SortExpression="NCI_ACCT" HeaderText="NCI Account" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:TemplateColumn >
<ItemTemplate>
sdgsdgs
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn >
<ItemTemplate>
<asp:UpdatePanel ID="dgChild2Panel" runat="server" UpdateMode=always>
<ContentTemplate>
<asp:PlaceHolder ID="phChild1" Visible="false" runat="server" >
</td></tr>
<tr> <td width="7"> </td>
<td colspan="12">
<asp:DataGrid ID="dgChild2" BorderStyle = "Solid" BorderWidth="1px" BorderColor ="white" Width="1000px" FooterStyle-Height="1px" PagerStyle-Mode="NumericPages" AllowCustomPaging="True" AllowPaging="True" AllowSorting="True" ShowFooter="True" AutoGenerateColumns="false" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" CssClass ="grid_body" >
<ItemStyle BorderStyle =Solid BorderWidth =1px CssClass="grid_body"></ItemStyle>
<HeaderStyle BorderStyle =Solid BorderWidth =1px CssClass="grid_header"></HeaderStyle>
<Columns>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" ItemStyle-Width = "120px" DataField="INTRACT_NO" SortExpression="INTRACT_NO" HeaderText="Ship To Interact" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "300px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="CUST_NM" SortExpression="CUST_NM" HeaderText="Name" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "300px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="SHIPTO_ADDR" SortExpression="SHIPTO_ADDR" HeaderText="Address" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "200px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="SHP_TYP" SortExpression="SHP_TYP" HeaderText="Ship To Type" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "100px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="COT_CD" SortExpression="COT_CD" HeaderText="COT Code" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "100px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="DDD_NO" SortExpression="DDD_NO" HeaderText="DDD Number" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
<asp:BoundColumn HeaderStyle-BorderStyle = Solid HeaderStyle-BorderColor =white HeaderStyle-BorderWidth ="1px" ItemStyle-BorderColor =white ItemStyle-HorizontalAlign= "left" ItemStyle-Width = "100px" ItemStyle-BorderStyle =Solid ItemStyle-BorderWidth ="1px" DataField="DEA_NO" SortExpression="DEA_NO" HeaderText="DEA Number" HeaderStyle-ForeColor ="Blue"></asp:BoundColumn>
</Columns>
<PagerStyle Height ="1px" NextPageText="Next &gt;" PrevPageText="&lt; Prev" CssClass="pager" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
</asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Height ="1px" NextPageText="Next &gt;" PrevPageText="&lt; Prev" CssClass="pager" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
</asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<HeaderStyle Width="1px" />
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Next &gt;" PrevPageText="&lt; Prev" CssClass="pager" Mode="NumericPages"></PagerStyle>
</asp:DataGrid>
</ContentTemplate>
</asp:UpdatePanel>

</DIV>

<table align="center" width="100%" >
<tr>
<td width="70px" ></td>
<td align="left">Rows per Page: <asp:TextBox id="ROWSPERPAGE" CssClass="field1" runat="server" AutoPostBack="False"></asp:TextBox>
<asp:Button id="CHANGEROWSPERPAGE" runat="server" CssClass="submit" Text="Change"></asp:Button>
</td>
</tr>
</table>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>

</form>
</body>
</html>

This is my code behind page

--------------

#Region "Imported Namespaces"
Imports System
Imports System.Collections
Imports System.Data
Imports System.Data.OracleClient
Imports System.Data.OracleClient.OracleType
Imports System.Web
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Configuration
#End Region

Partial Class HierGrid
Inherits System.Web.UI.Page
#Region "Class level Variables"
Protected OracleConn As OracleConnection
Protected OracleCmd As OracleCommand
Protected OracleDR As OracleDataReader
Protected OracleReader As OracleDataReader
Dim StrSQL As String
Dim modifiedOrderby As String
Dim orderby As String
Dim direction As String
Dim pageindex As String
Dim maximumrows As Integer
Dim vartemp As String
Dim strParentId As String
Dim strInteractId As String

#End Region

#Region "Properties"
Protected Property dgParent_CurrentSortColumn() As String
Get
If Not ViewState("dgParentSortColumn") Is Nothing Then
Return ViewState("dgParentSortColumn").ToString
Else
ViewState("dgParentSortColumn") = "CONTR_ID"
Return "CONTR_ID"
End If
End Get
Set(ByVal value As String)
ViewState("dgParentSortColumn") = value
End Set
End Property

Protected Property dgParent_CurrentSortDirection() As String
Get

If Not ViewState("dgParentSortDirection") Is Nothing Then
Return ViewState("dgParentSortDirection").ToString
Else
ViewState("dgParentSortDirection") = "ASC"
Return "ASC"
End If
End Get
Set(ByVal value As String)
ViewState("dgParentSortDirection") = value
End Set
End Property


Protected Property dgChild1_CurrentSortColumn() As String
Get
If Not ViewState("dgChild1SortColumn") Is Nothing Then
Return ViewState("dgChild1SortColumn").ToString
Else
ViewState("dgChild1SortColumn") = "INTRACT_NO"
Return "INTRACT_NO"
End If
End Get
Set(ByVal value As String)
ViewState("dgChild1SortColumn") = value
End Set
End Property

Protected Property dgChild1_CurrentSortDirection() As String
Get

If Not ViewState("dgChild1SortDirection") Is Nothing Then
Return ViewState("dgChild1SortDirection").ToString
Else
ViewState("dgChild1SortDirection") = "ASC"
Return "ASC"
End If
End Get
Set(ByVal value As String)
ViewState("dgChild1SortDirection") = value
End Set
End Property

Protected Property dgChild2_CurrentSortColumn() As String
Get
If Not ViewState("dgChild2SortColumn") Is Nothing Then
Return ViewState("dgChild2SortColumn").ToString
Else
ViewState("dgChild2SortColumn") = "INTRACT_NO"
Return "INTRACT_NO"
End If
End Get
Set(ByVal value As String)
ViewState("dgChild2SortColumn") = value
End Set
End Property

Protected Property dgChild2_CurrentSortDirection() As String
Get

If Not ViewState("dgChild2SortDirection") Is Nothing Then
Return ViewState("dgChild2SortDirection").ToString
Else
ViewState("dgChild2SortDirection") = "ASC"
Return "ASC"
End If
End Get
Set(ByVal value As String)
ViewState("dgChild2SortDirection") = value
End Set
End Property
#End Region

#Region "Pagelevel Events"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
StrSQL = "SELECT COUNT(1) AS C FROM RCS_CONTR"
GetTotalRecords(StrSQL, dgParent)
dgParent_CurrentSortColumn = "CONTR_ID"
dgParent_CurrentSortDirection = "ASC"
dgParent.CurrentPageIndex = 0
dgParent.PageSize = 10
ActualPagedData(dgParent)
ROWSPERPAGE.Text = dgParent.PageSize.ToString()

End If
End Sub
#End Region

#Region "User Defined Methods"
Private Sub GetTotalRecords(ByVal StrSQL As String, ByVal ogrid As DataGrid)
Try

OracleConn = New OracleConnection(ConfigurationManager.AppSettings("ConnectionString").ToString)
Size=3;Max Pool Size=50;Connection Lifetime=7200;")
OracleConn.Open()
OracleCmd = New OracleCommand(StrSQL, OracleConn)
OracleCmd.CommandType = CommandType.Text
OracleDR = OracleCmd.ExecuteReader
OracleDR.Read()
ogrid.VirtualItemCount = CType(OracleDR.GetDecimal(0), Integer)

Catch ORCLExec As OracleException
Response.Write(ORCLExec.Message)

Finally
If Not OracleDR Is Nothing Then
OracleDR.Close()
End If
If Not OracleCmd Is Nothing Then
OracleCmd.Dispose()
End If
If Not OracleConn Is Nothing Then
OracleConn.Close()
End If
End Try
End Sub

Private Sub ActualPagedData(ByVal oGrid As DataGrid)

Dim modifiedOrderby As String
Dim SQLString, SQLCount As String

Try
Dim Lowlmt As Decimal = (1 + oGrid.CurrentPageIndex * oGrid.PageSize + oGrid.PageSize)
Dim Highlmt As Decimal = (1 + oGrid.CurrentPageIndex * oGrid.PageSize)
SQLString = String.Empty
If oGrid.UniqueID = dgParent.UniqueID Then
modifiedOrderby = dgParent_CurrentSortColumn & " " & dgParent_CurrentSortDirection

SQLString = " SELECT CONTR_ID,CONTR_NO,CONTR_NM,CONTR_ADDR,TO_CHAR(EFFTV_STRT_DT,'MM/DD/YYYY') AS EFFTV_STRT_DT,TO_CHAR(EFFTV_END_DT,'MM/DD/YYYY') AS EFFTV_END_DT " & _
" FROM (SELECT P.*, " & _
" ROWNUM RNUM " & _
" FROM (SELECT A.CONTR_ID,A.CONTR_NO,A.CONTR_NM, B.ADDR1||','||B.CITY||','||B.STT_ABBRD||','||B.ZIP AS CONTR_ADDR,A.EFFTV_STRT_DT,A.EFFTV_END_DT " & _
" FROM RCS_CONTR A, hcms_addr B WHERE " & _
" A.ADDR_ID = B.ADDR_ID (+) " & _
" ORDER BY " & modifiedOrderby & ") P " & _
" WHERE ROWNUM < " & Lowlmt & ")" & _
" WHERE RNUM >= " & Highlmt & ""

ElseIf oGrid.UniqueID = dgChild1.UniqueID Then
' oGrid.Height = 1000
oGrid.CurrentPageIndex = CType(Session("child1_pageindex"), Integer)
modifiedOrderby = dgChild1_CurrentSortColumn & " " & dgChild1_CurrentSortDirection
SQLString = " SELECT PARNT_INTRACT_NO,INTRACT_NO,CUST_NM,CUST_ADDR,CUST_TYP,DEA_NO,DECODE(PHS_ELGBLT,'Y','YES','N','NO') AS PHS_ELGBLT,TO_CHAR(RELSHP_STRT_DT,'MM/DD/YYYY') AS RELSHP_STRT_DT,TO_CHAR(RELSHP_END_DT,'MM/DD/YYYY') AS RELSHP_END_DT,INTRACT_COT_CD,DDD_NO,DECODE(NCI_ACCT,'Y','YES','N','NO') AS NCI_ACCT " & _
" FROM (SELECT P.*, " & _
" ROWNUM RNUM " & _
" FROM (SELECT A.PARNT_INTRACT_NO,A.INTRACT_COT_CD,D.PARM_VAL AS CUST_TYP , A.INTRACT_NO,A.CUST_NM,C.ADDR1||','||C.CITY||','||C.STT_ABBRD||','||C.ZIP AS CUST_ADDR ,A.BIO_ID,A.IN_PATNT_DEA AS DEA_NO,B.PHS_ELGBLT,B.RELSHP_STRT_DT,B.RELSHP_END_DT,DDD_NO,B.NCI_ACCT " & _
" FROM RCS_CUST A,RCS_CONTR_CUST_MAP B,hcms_addr C,RCS_LKUP D " & _
" WHERE A.INTRACT_NO = B.INTRACT_NO AND A.ADDR_ID = C.ADDR_ID(+) AND " & _
" A.CUST_TYP = D.PARM_ID (+) AND UPPER(D.PARM_NM) = 'CUSTOMER TYPE' AND "
If Session("ContractID") <> "" Then SQLString = SQLString & " B.CONTR_ID = '" & Trim(Session("ContractID")) & "'"
SQLString = SQLString & " ORDER BY " & modifiedOrderby & ") P" & _
" WHERE ROWNUM < " & Lowlmt & ")" & _
" WHERE RNUM >= " & Highlmt & ""
SQLCount = " SELECT count(*) " & _
" FROM (SELECT P.*, " & _
" ROWNUM RNUM " & _
" FROM (SELECT A.PARNT_INTRACT_NO,A.INTRACT_COT_CD,D.PARM_VAL AS CUST_TYP , A.INTRACT_NO,A.CUST_NM,C.ADDR1||','||C.CITY||','||C.STT_ABBRD||','||C.ZIP AS CUST_ADDR ,A.BIO_ID,A.IN_PATNT_DEA AS DEA_NO,B.PHS_ELGBLT,TO_CHAR(B.RELSHP_STRT_DT,'MM/DD/YYYY'),TO_CHAR(B.RELSHP_END_DT,'MM/DD/YYYY'),DDD_NO,B.NCI_ACCT " & _
" FROM RCS_CUST A,RCS_CONTR_CUST_MAP B,hcms_addr C,RCS_LKUP D " & _
" WHERE A.INTRACT_NO = B.INTRACT_NO AND A.ADDR_ID = C.ADDR_ID(+) AND " & _
" A.CUST_TYP = D.PARM_ID (+) AND UPPER(D.PARM_NM) = 'CUSTOMER TYPE' AND "
If Session("ContractID") <> "" Then SQLCount = SQLCount & " B.CONTR_ID = '" & Trim(Session("ContractID")) & "'"
SQLCount = SQLCount & " ORDER BY " & modifiedOrderby & ") P " & ")"
Try
OracleConn = New OracleConnection(ConfigurationManager.AppSettings("ConnectionString").ToString)
Pool Size=3;Max Pool Size=50;Connection Lifetime=7200;")
OracleConn.Open()
OracleCmd = New OracleCommand(SQLCount, OracleConn)
OracleCmd.CommandType = CommandType.Text
OracleReader = OracleCmd.ExecuteReader
OracleReader.Read()
oGrid.VirtualItemCount = CType(OracleReader.GetDecimal(0), Integer)
Catch OraEx As OracleException
Response.Write(OraEx.Message)
Finally
If Not OracleReader Is Nothing Then
OracleReader.Dispose()
End If
If Not OracleCmd Is Nothing Then
OracleCmd.Dispose()
End If
If Not OracleConn Is Nothing Then
OracleConn.Close()
End If
End Try
ElseIf oGrid.UniqueID = dgChild2.UniqueID Then
modifiedOrderby = dgChild2_CurrentSortColumn & " " & dgChild2_CurrentSortDirection
SQLString = " SELECT INTRACT_NO, CUST_NM , SHIPTO_ADDR ,SHP_TYP,COT_CD,DEA_NO ,DDD_NO " & _
" FROM (SELECT P.*, " & _
" ROWNUM RNUM " & _
" FROM (SELECT A.INTRACT_NO,A.CUST_NM,B.ADDR1||','||B.CITY||','||B.STT_ABBRD||','||B.ZIP AS SHIPTO_ADDR,A.INTRACT_COT_CD AS COT_CD,A.IN_PATNT_DEA AS DEA_NO,A.DDD_NO,C.PARM_VAL AS SHP_TYP FROM RCS_CUST A ,hcms_addr B , RCS_LKUP C WHERE " & _
" A.ADDR_ID = B.ADDR_ID (+) " & _
" AND A.SHP_TO_TYP = C.PARM_ID (+) "
If Session("InteractID") <> "" Then SQLString = SQLString & " and parnt_intract_no = '" & Trim(Session("InteractID")) & "'"
SQLString = SQLString & " ORDER BY " & modifiedOrderby & ") P " & _
" WHERE ROWNUM < " & Lowlmt & ")" & _
" WHERE RNUM >= " & Highlmt & ""

SQLCount = " SELECT count(*) " & _
" FROM (SELECT P.*, " & _
" ROWNUM RNUM " & _
" FROM (SELECT A.INTRACT_NO,A.CUST_NM,B.ADDR1||','||B.CITY||','||B.STT_ABBRD||','||B.ZIP AS SHIPTO_ADDR,A.INTRACT_COT_CD AS COT_CD,A.IN_PATNT_DEA AS DEA_NO,A.DDD_NO,C.PARM_VAL AS SHP_TYP FROM RCS_CUST A ,hcms_addr B , RCS_LKUP C WHERE " & _
" A.ADDR_ID = B.ADDR_ID (+) " & _
" AND A.SHP_TO_TYP = C.PARM_ID (+) "
If Session("InteractID") <> "" Then SQLCount = SQLCount & " and parnt_intract_no = '" & Trim(Session("InteractID")) & "'"
SQLCount = SQLCount & " ORDER BY " & modifiedOrderby & ") P " & ")"

Try
OracleConn = New OracleConnection(ConfigurationManager.AppSettings("ConnectionString").ToString)
Pool Size=3;Max Pool Size=50;Connection Lifetime=7200;")
OracleConn.Open()
OracleCmd = New OracleCommand(SQLCount, OracleConn)
OracleCmd.CommandType = CommandType.Text
OracleReader = OracleCmd.ExecuteReader
OracleReader.Read()
oGrid.VirtualItemCount = CType(OracleReader.GetDecimal(0), Integer)
Catch OraEx As OracleException
Response.Write(OraEx.Message)
Finally
If Not OracleReader Is Nothing Then
OracleReader.Dispose()
End If
If Not OracleCmd Is Nothing Then
OracleCmd.Dispose()
End If
If Not OracleConn Is Nothing Then
OracleConn.Close()
End If
End Try
End If
OracleConn = New OracleConnection(ConfigurationManager.AppSettings("ConnectionString").ToString)
OracleConn.Open()
OracleCmd = New OracleCommand(SQLString, OracleConn)
OracleCmd.CommandType = CommandType.Text
oGrid.DataSource = OracleCmd.ExecuteReader
oGrid.DataBind()


Catch OraEx As OracleException
Response.Write(OraEx.Message)
Finally
If Not OracleCmd Is Nothing Then
OracleCmd.Dispose()
End If
If Not OracleConn Is Nothing Then
OracleConn.Close()
End If
End Try
End Sub

Protected Sub CHANGEROWSPERPAGE_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CHANGEROWSPERPAGE.Click

Try

Session("ContractID") = ""
Dim Lowlmt As Decimal = (1 + dgParent.CurrentPageIndex * dgParent.PageSize + dgParent.PageSize)
Dim Highlmt As Decimal = (1 + dgParent.CurrentPageIndex * dgParent.PageSize)
Dim newPageIndex, newPageSize As Integer
newPageSize = CType(ROWSPERPAGE.Text, Integer)
newPageIndex = CType((Highlmt / newPageSize), Integer)
dgParent.CurrentPageIndex = newPageIndex
dgParent.PageSize = newPageSize
ActualPagedData(dgParent)
Catch ex As Exception
Response.Write("Please enter a valid integer to change the number of rows per page.")
End Try
End Sub
#End Region

#Region "ParentDataGrid Event Handlers"

Protected Sub dgParent_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgParent.ItemCommand
If e.CommandName = "Expand" Then
Dim imgBtn As ImageButton
Dim pHolder As PlaceHolder

'Before expanding, collapse previously opened child grid
Dim dgItem As DataGridItem
For Each dgItem In dgParent.Items
If dgItem.ItemIndex = ViewState("PrvIndex") And dgItem.ItemIndex <> e.Item.ItemIndex Then
imgBtn = dgItem.Cells(0).FindControl("imgBtnParent")
If imgBtn.ImageUrl = "~/Images/minus.gif" Then
imgBtn.ImageUrl = "~/Images/plus.gif"
pHolder = CType(dgItem.FindControl("phParent"), PlaceHolder)
pHolder.Visible = Not pHolder.Visible
End If
Exit For
End If
Next
' Get the contract id for which to display customers
strParentId = e.Item.Cells(1).Text
Session("ContractID") = strParentId

imgBtn = e.Item.Cells(0).FindControl("imgBtnParent")
If imgBtn.ImageUrl = "~/Images/plus.gif" Then
imgBtn.ImageUrl = "~/Images/minus.gif"

Else
imgBtn.ImageUrl = "~/Images/plus.gif"
End If
Dim exp As PlaceHolder
exp = e.Item.Cells(5).FindControl("phParent")
exp.Visible = Not exp.Visible
If exp.Visible = True Then
dgChild1.CurrentPageIndex = 0
ActualPagedData(dgParent)
End If
'Get the previous selected index in order to collapse the previous DataGrid
ViewState("PrvIndex") = e.Item.ItemIndex

End If
End Sub

Protected Sub dgParent_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgParent.ItemDataBound
' It will be called on binding each and every row of the datagrid to datasource

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then

If e.Item.Cells(1).Text.Equals(Session("ContractID")) Then
Dim imgBtn As ImageButton
imgBtn = e.Item.Cells(0).FindControl("imgBtnParent")
imgBtn.ImageUrl = "~/Images/minus.gif"
Dim exp As PlaceHolder
exp = e.Item.Cells(5).FindControl("phParent")
exp.Visible = True
dgChild1.PageSize = CType(ROWSPERPAGE.Text, Integer)
'Session("InteractID") = ""
ActualPagedData(dgChild1)
End If
End If
End Sub

Protected Sub dgParent_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgParent.PageIndexChanged
dgParent.CurrentPageIndex = e.NewPageIndex
Session("ContractID") = ""
ActualPagedData(dgParent)
End Sub

Protected Sub dgParent_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgParent.SortCommand
' Dim direction As String

'Check if this is the second time the same column name is selected (this means we need to sort descending)
' Otherwise, the sort should be done ascending since this is a new column (compared to the one saved in the
' view state) that was selected.
If (dgParent_CurrentSortDirection = "ASC" And dgParent_CurrentSortColumn = e.SortExpression) Then
dgParent_CurrentSortDirection = "DESC"
Else
dgParent_CurrentSortDirection = "ASC"
End If
' Remember what column the data is sorted by.
dgParent_CurrentSortColumn = e.SortExpression
Session("ContractID") = ""
dgParent.CurrentPageIndex = 0
ActualPagedData(dgParent)
End Sub
#End Region

#Region "Second level Grid Event Handlers"

Protected Sub dgChild1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
If e.CommandName = "ExpChild1" Then
Dim imgBtnChild As ImageButton
Dim pHChild As PlaceHolder

Dim dgItem As DataGridItem

Dim dgChild As DataGrid
Dim dgItemChild As DataGridItem

For Each dgItem In dgParent.Items
dgChild = CType(dgItem.FindControl("dgChild1"), DataGrid)

For Each dgItemChild In dgChild.Items
If dgItemChild.ItemIndex = ViewState("prvChIndex") And dgItemChild.ItemIndex <> e.Item.ItemIndex Then
imgBtnChild = dgItemChild.Cells(0).FindControl("imgBtnChild")
If imgBtnChild.ImageUrl = "~/Images/minus.gif" Then
imgBtnChild.ImageUrl = "~/Images/plus.gif"
pHChild = dgItemChild.Cells(2).FindControl("pHChild1")
pHChild.Visible = Not pHChild.Visible
End If
Exit For
End If
Next
Next


strInteractId = e.Item.Cells(1).Text
Session("InteractID") = strInteractId

imgBtnChild = e.Item.Cells(0).FindControl("imgBtnChild")
If imgBtnChild.ImageUrl = "~/Images/plus.gif" Then
imgBtnChild.ImageUrl = "~/Images/minus.gif"
Else
imgBtnChild.ImageUrl = "~/Images/plus.gif"
End If

pHChild = e.Item.Cells(2).FindControl("phChild1")
pHChild.Visible = Not pHChild.Visible

If pHChild.Visible = True Then
dgChild2.CurrentPageIndex = 0
'ActualPagedData(dgChild1)
ActualPagedData(dgParent)
End If

ViewState("prvChIndex") = e.Item.ItemIndex
'pHChild.Visible = True

End If
End Sub

Protected Sub dgChild1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgChild1.Init

End Sub

Protected Sub dgChild1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgChild1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
If e.Item.Cells(1).Text.Equals(Session("InteractID")) Then
Dim imgBtn As ImageButton
imgBtn = e.Item.Cells(0).FindControl("imgBtnChild")
imgBtn.ImageUrl = "~/Images/minus.gif"
Dim exp As PlaceHolder
exp = e.Item.Cells(5).FindControl("phChild1")
exp.Visible = True
' dgChild2.PageSize = CType(ROWSPERPAGE.Text, Integer)
dgChild2.PageSize = 1
ActualPagedData(dgChild2)
End If
End If
End Sub

Protected Sub dgChild1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
Dim dgchild As New DataGrid
dgChild1.CurrentPageIndex = e.NewPageIndex
Session("child1_pageindex") = e.NewPageIndex
dgChild1.PageSize = CType(ROWSPERPAGE.Text, Integer)
Session("InteractID") = ""
ActualPagedData(dgChild1)
End Sub

Protected Sub dgChild1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)
'Check if this is the second time the same column name is selected (this means we need to sort descending)
' Otherwise, the sort should be done ascending since this is a new column (compared to the one saved in the
' view state) that was selected.
If (dgChild1_CurrentSortDirection = "ASC" And dgChild1_CurrentSortColumn = e.SortExpression) Then
dgChild1_CurrentSortDirection = "DESC"
Else
dgChild1_CurrentSortDirection = "ASC"
End If
' Remember what column the data is sorted by.
dgChild1_CurrentSortColumn = e.SortExpression

'Reselect the set of data to show. Note that the page index is reset to 0.
dgChild1.CurrentPageIndex = 0
Session("InteractID") = ""

ActualPagedData(dgChild1)

End Sub
#End Region

#Region "Third level Grid Event Handlers"
Protected Sub dgChild2_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgChild2.SortCommand
'Check if this is the second time the same column name is selected (this means we need to sort descending)
' Otherwise, the sort should be done ascending since this is a new column (compared to the one saved in the
' view state) that was selected.
If (dgChild2_CurrentSortDirection = "ASC" And dgChild2_CurrentSortColumn = e.SortExpression) Then
dgChild2_CurrentSortDirection = "DESC"
Else
dgChild2_CurrentSortDirection = "ASC"
End If
' Remember what column the data is sorted by.
dgChild2_CurrentSortColumn = e.SortExpression
' Make sure the page remembers the sorting direction.
'Reselect the set of data to show. Note that the page index is reset to 0.
dgChild2.CurrentPageIndex = 0
ActualPagedData(dgChild2)
End Sub

Protected Sub dgChild2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgChild2.ItemDataBound

End Sub

Protected Sub dgChild2_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgChild2.PageIndexChanged
dgChild2.CurrentPageIndex = e.NewPageIndex
ActualPagedData(dgChild2)
End Sub

#End Region

End Class

Paging and Sorting in GridView April CTP

Hi,

This start happing only after I upgraded to April release, with March release there was no problem.

I'm using updatepanel and gridview and have a ObjectDataSource which get some QueryStringParameter from the Request. When I'm trying to sort the gridview I'm getting a javascript error saying "Value cannot be null. Parameter name: error.

When trying to debug it I found that when sorting, the request URL got changed, and for example if the URL was :http://mySite.com/Default.aspx?kw=123&from=4/18/2006&to=4/19/2006

It got changed to :http://mySite.com/Default.aspx?kw=123&from=4/18/2006&to=4/19/2006Default.aspx?kw=123&from=4/18/2006&to=4/19/2006

Any thoughts?

Thanks

L

Hi,

I found the cause of the problem.

When ever there is a parameter in the URL that has \ like: &to=4\1\2006&..

Atlas April CTP is going crazy... and can't handle that. I have changed my date format to 4_1_2006 etc. and it's working, but still it's kind of a big deal.

Can any one confirm it's a known bug?

Thanks

Lior

Paging and UpdatePanel

Hi,

If you look at this page you see an example of paging within an update panel which works well

http://mattberseth2.com/resizeable_gridview_columns/


The difference I have is I also have ajaxToolkit:HoverMenuExtender on my first column which popups 'Edit Details' text which takes you to a new page...

without any triggers on the updatepanel, my paging now works as the above example.. but when I use my hover menu and click on 'Edit Detail' I get the following error..


Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '

to fix this error I use the following trigger on the updatepanel

<Triggers>
<asp:PostBackTrigger ControlID="GridView1" />
</Triggers>

now when I click on Edit Details it takes me to the new page as intended... but when I click on my paging buttons it doesnt work within the update panel it causes full page reload..

any ideas to get these two working together would be appreciated...


I have newver try that, I actually just added the GridView inside an UpdatePanel and seem to work really well


Hi,

Generally, I think implement it as Albert suggested should work.

If still not, please provide a simple repro that demonstrate the first problem(Sys.WebForms.PageRequestManagerParserErrorException: The messagereceived from the server could not be parsed. Common causes for thiserror are when the response is modified by calls to Response.Write(),response filters, HttpModules, or server trace is enabled. Details:Error parsing near ' ).


Hi,

simple repro.. would be to grab the example from the above link... and add following hovermenu to first column... add pagertemplate below...

paging works fine within the updatepanel

on clicking edit details you get the error as described in the first post...

to fix this error I use the following trigger on the updatepanel

<Triggers>
<asp:PostBackTrigger ControlID="GridView1" />
</Triggers>

but now the paging causes full page post back..

adding thelnkBtnRowEditDetail as a trigger as well dosent work as that gives a control id cant be found error.

 <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:Panel CssClass="popupMenu" ID="PopupMenuCustomerName" runat="server"> <div class="popupMenuButtons"> <asp:LinkButton ID="lnkBtnRowEdit" SkinID="SmallTextPopUp" runat="server" CommandName="Edit" Text="Edit
</asp:LinkButton> <asp:LinkButton ID="lnkBtnRowEditDetail" SkinID="SmallTextPopUp" runat="server" CommandName="EditDetail" Text="Edit Detail"></asp:LinkButton> </div> </asp:Panel> <asp:Panel ID="PanelCustomerName" runat="server"> <asp:ImageButton ID="ImgButton" runat="server" AlternateText="Edit" ImageUrl="~/images/icon_edit.gif" CausesValidation="false" CommandName="" /> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme3" runat="Server" HoverCssClass="popupHover" PopupControlID="PopupMenuCustomerName" PopupPosition="Left" TargetControlID="PanelCustomerName" PopDelay="15"> </ajaxToolkit:HoverMenuExtender> </ItemTemplate> <EditItemTemplate> <asp:Panel CssClass="popupMenu" ID="PopupMenuCustomerName" runat="server"> <div class="popupMenuButtons"> <asp:LinkButton ID="lnkBtnRowUpdate" SkinID="SmallTextPopUp" runat="server" CommandName="Update" Text="Update"></asp:LinkButton><br /> <asp:LinkButton ID="lnkBtnRowCancel" SkinID="SmallTextPopUp" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </div> </asp:Panel> <asp:Panel ID="PanelCustomerName" runat="server"> <asp:ImageButton ID="ImgButton" runat="server" AlternateText="Update/Cancel" ImageUrl="~/images/icon_edit.gif" CausesValidation="false" CommandName="" /> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme3" runat="Server" HoverCssClass="popupHover" PopupControlID="PopupMenuCustomerName" PopupPosition="Left" TargetControlID="PanelCustomerName" PopDelay="15"> </ajaxToolkit:HoverMenuExtender> </EditItemTemplate> </asp:TemplateField>

 <PagerTemplate> <div class="item"> <div class="item_left"> <asp:Label ID="lblPageTxt" runat="server" SkinID="PageSmallText" EnableViewState="false" Text="Page" ></asp:Label> <asp:DropDownList ID="PageDropDownList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageDropDownList_SelectedIndexChanged" /> <asp:Label ID="lblOfTxt" runat="server" SkinID="PageSmallText" EnableViewState="false" Text="of"></asp:Label> <asp:Label ID="lbTotalPages" runat="server" SkinID="PageSmallText"></asp:Label> </div> <div class="item_right"> <asp:ImageButton ID="imgbtnFirst" runat="server" CommandName="Page" CommandArgument="First" ImageUrl="~/images/arrow_up.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnPrev" runat="server" CommandName="Page" CommandArgument="Prev" ImageUrl="~/images/arrow_left.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnNext" runat="server" CommandName="Page" CommandArgument="Next" ImageUrl="~/images/arrow_right.gif"></asp:ImageButton> <asp:ImageButton ID="imgbtnLast" runat="server" CommandName="Page" CommandArgument="Last" ImageUrl="~/images/arrow_down.gif"></asp:ImageButton> </div> <div class="clear"></div> </div> </PagerTemplate>

not using the hovermenu isnt really an option... as this functionality is consistent with the rest of the site... unless you have another idea for reproducing this functionality

first column of our gridviews are a basic icon image... with a hover menu that has 'Edit' which edits gridview inline 'Edit Details' which goes to a new page ... they also have 'Clone' which provides a modal popup and 'Create Link'/'Remove Link' and other such functionlaity... which is available from the gridview using the hovermenu.



Would you mind showing a repro that I can run directly?


Hi Paul

I looked at the example at

http://mattberseth2.com/resizeable_gridview_columns/

and it looks great.
Can you share your code?

Thanks

Shalom


there is example code on that link... http://mattberseth2.com/resizeable_gridview_columns/

Paging Bullet List Extender

I am trying to use PagingBulletedListExtender in my Project (VS 2005). When I used the demo data which was around 500 records it was working fine. But now when I have tried to connect bullet list control with more than 13000 records it has hanged. I am not surprised with this as I understand that this is a huge amount of data and no matter what application will hang. I wish there could be some way where we can get only that data which is required. One of the problem with Paging bullet list control is that the header bullet (A - B-C-D-E...) doesn't get generated till thhe time there is no corresponding data (which is a good thing in other sense). We solved this problem by getting all the records for first bullet and one record for rest of the bullet points, so this way we have specific amount of data. But I was surprised after that I could not find any other event which gets called when user has clicked the header bullet that is A-B-C-D-E-F-G........ If I could find this event I can always pass the bullet which user has user clicked and get the rest of the data. There is click event which is fired when we click any of the items in the bullet list control.

The only solution to my problem which I thought was to create two bullet controls. One for showing the alphabets and another for showing the data. I do not require the Paging Bullet control now. But I am really surprised that there is no event related to this or may be I was not able to find it. No I have to re-do this part again.

It would be really great if there is a event and some one can suggest that OR for the next version we can add this event.

Thanks,

Archna

Hi Archna,

Please create an item for this feature requesthere. So that it can be noticed by our product group.

Please also post the item's URL in this thread so that it may help others. Thanks.

Paging freeze after partial postback

HiI am a newbie to the AJAX stage, I created an application very similar in functionality as the to do list HDI video demo.My problem is when I do a partial page back and the new data is refreshed into my gridview the paging stops to function. You can click on the page numbers and there it will stay till I fire

a full page postback. I have an updatePanel with a Gridview and a dropdownlist included in the panel. The dropdownlist just selects different departments in our organization.

I set the updatePanel to conditionalupdate and specified my trigger as dorpdownlist selected index change, enabled the paging and enablepagingandsorting on my gridview.

What did I miss on my path to AJAX ?

Can you post your code where its freezing. Check with breakpoints?


hello.

if the dropdown is inside the panel, then you simply don't need to set up triggers.

btw, here's a quick example:

i have the following ona code file on app_code:

public class Obj
{
private Int32 _id;
private String _name;

public int Id
{
get { return _id; }
set { _id = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}
}


public class ObjDS
{
public List<Obj> Get()
{
List<Obj> objs = new List<Obj>
{
new Obj{Id = 1, Name = "Luis"} ,
new Obj{Id = 2, Name = "Jose"} ,
new Obj{Id = 3, Name = "Jose"} ,
new Obj{Id = 4, Name = "Jose"}

}
;
return objs;
}
}

and then, on an aspx page, i have this:

<asp:ScriptManager runat="server" ID="manager" />
<asp:UpdatePanel runat="server" ID="panel">
<contenttemplate>
<asp:GridView ID="GridView1" runat="server"
PageSize="2"
DataSourceID="source" AllowPaging="true">
</asp:GridView>

<asp:ObjectDataSource
TypeName="ObjDs"
SelectMethod="Get"
ID="source" runat="server">
</asp:ObjectDataSource>
<%= DateTime.Now.ToString() %>
</contenttemplate>
</asp:UpdatePanel>

it's working here. does it work there?


Hi LuisThanks for the reply.I am using a database queried created dataset and not a custom dataset,does this make a difference?What gets me is that after the page has loaded for a first time the paging works and after a partial postback the rest of the controls workexcept the datagrid's paging.

I'll have a crack at your code and let you know.


Hi Dexza,

Here is a working sample which is written based on your description. Please compare it with yours.

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.DropDownList1.Items.Add("111");
this.DropDownList1.Items.Add("222");
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{

}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<%=DateTime.Now.ToString()%>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" PageSize="2" AllowPaging="true">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" InsertVisible="False"
ReadOnly="True" SortExpression="EmployeeID" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString%>"
SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [Title] FROM [Employees]"
DeleteCommand="DELETE FROM [Employees] WHERE [EmployeeID] = @.EmployeeID" InsertCommand="INSERT INTO [Employees] ([LastName], [FirstName], [Title]) VALUES (@.LastName, @.FirstName, @.Title)"
UpdateCommand="UPDATE [Employees] SET [LastName] = @.LastName, [FirstName] = @.FirstName, [Title] = @.Title WHERE [EmployeeID] = @.EmployeeID">
<DeleteParameters>
<asp:Parameter Name="EmployeeID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>

Best regards,

Jonathan


Hello.

Jonathan, i haven't run the code, but i'm curious: why did you associate a trigger with a server control that is inside an updatepanel?


Hi Luis Abreu,

Thanks for your attention. I just generated a sample based on the description of the thread owner. Yes , I agree with you that we don't need a trigger in this situation. Thanks

Best regards,

Jonathan


hello again.

well, i just asked because i might be missing something...thanks for the clarification.


Hi guys I have found my problem regarding the paging issue fromContributor post I noticed that on his properties he had only AllowPaging set to true and I had AllowPaging and EnablePagingAndSortingCallback set to true. So I changed it to false and of we go. Paging and sorting is up and running. Now I still have the problem where after selecting something different from my dorpdownlist that the updating does not work, but if I go back to the data the page was loaded with it works fine. So I have two questions. Why does the paging and sorting stop to function with a partial postback if EnablePagingAndSortingCallback is set to true. And what is wrong with the update function. Here is my code.

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%> <%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1"%> <!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"> <title>Untitled Page</title> <linkhref="StyleSheet.css"rel="stylesheet"type="text/css"/></head> <body> <formid="form1"runat="server"> <asp:ScriptManagerID="ScriptManager1"runat="server"/> <br/> <br/> <br/> <br/> <asp:PanelID="Panel2"runat="server"BorderColor="Silver"BorderStyle="Solid"BorderWidth="1px" Height="50px"Width="125px"> <asp:UpdatePanelID="UpdatePanel1"runat="server"EnableViewState="False"UpdateMode="Conditional"> <ContentTemplate> <asp:GridViewID="GridView1"runat="server"AllowPaging="True" AutoGenerateColumns="False"BackColor="SteelBlue"DataKeyNames="IdeaNumber"DataSourceID="ObjectDataSource1"ForeColor="White"GridLines="None"Width="504px"AllowSorting="True"> <Columns> <asp:CommandFieldShowEditButton="True"/> <asp:BoundFieldDataField="IdeaNumber"HeaderText="IdeaNumber"InsertVisible="False" ReadOnly="True"SortExpression="IdeaNumber"/> <asp:BoundFieldDataField="IdeaName"HeaderText="IdeaName"SortExpression="IdeaName"/> <asp:CheckBoxFieldDataField="IdealDone"HeaderText="IdealDone"SortExpression="IdealDone"/> </Columns> <AlternatingRowStyleBackColor="LightBlue"ForeColor="SteelBlue"/> </asp:GridView> <asp:ObjectDataSourceID="ObjectDataSource1"runat="server"DeleteMethod="Delete" EnableViewState="False"InsertMethod="Insert"OldValuesParameterFormatString="original_{0}" SelectMethod="GetIdeaData"TypeName="IdeaDataSetTableAdapters.IdeaTableTableAdapter" UpdateMethod="Update"> <DeleteParameters> <asp:ParameterName="Original_IdeaNumber"Type="Int32"/> </DeleteParameters> <UpdateParameters> <asp:ParameterName="IdeaName"Type="String"/> <asp:ParameterName="IdealDone"Type="Boolean"/> <asp:ParameterName="Original_IdeaNumber"Type="Int32"/> </UpdateParameters> <SelectParameters> <asp:ControlParameterControlID="DropDownList1"Name="IsDone"PropertyName="SelectedValue" Type="Boolean"/> </SelectParameters> <InsertParameters> <asp:ParameterName="IdeaName"Type="String"/> <asp:ParameterName="IdealDone"Type="Boolean"/> </InsertParameters> </asp:ObjectDataSource> <asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"> <asp:ListItemValue="false">To do</asp:ListItem> <asp:ListItemValue="true">Completed</asp:ListItem> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowEditing"/> </Triggers> </asp:UpdatePanel> </asp:Panel> <br/> <br/> </form></body>

</html>


hello.

well, not sure on what's happening there...anyways, i'll just leave my 2 cents. first, if you have an updatepanel, i'm not sure if you'll be wining much with the grid's paging and sorting through callbakcs (if you have the time, compare the size of each request - yeah, i believe that through callbacks you'll have less to transport but you can't do other interesting things).

second, i can't seem to think of a good reason why the callback mechanism should not working with the updatepanel partial postbacks. try using fiddler to see what's happening between client and server...

Paging gridview inside ATLAS tabcontrol

Hi, I have a dynamicly generated gridview control, inside a dynamically generated tab control. I am having trouble paging the gridview. I get a viewstate corrupted error message at the moment. My page setup is something like this:

Inside the page object, I have an update panel.

Inside the update panel, I have a tab container.

Inside the tab container, I have a number of tabs decided dynamically on page load. There will always be one tab, which doesnt contain a gridview, but there can be other tabs, each containing just a single control, a pageable gridview.

I suspect the fix involves wrapping the gridview in another update panel, which is inside the tab object itself, and triggering the update event for the panel when it needs to page.

Can anyone give me some advice, let me know if I am along the right lines?


Many thanks, Andrew Jones

please take alook at this:

http://forums.asp.net/p/1108841/1703584.aspx

Paging in GridView gets Object Expected Error

I have a grid in an update panel that gets databound at runtime (to index server results). I have implemented paging and it works without atlas. As soon as I place that grid in update panel, paging stops working. All I get is a javascript error saying "line 1 :Object Requiered".

I have tried debugging it but on paging, it doesn't event get to the server.

thanks

Hi Biren,

Have you tried this with the April CTP of Atlas that was released earlier this week?

If it's still a problem, can you please provide some more details on your scenario so that we can investigate?

Thanks,

Eilon


I have done it and it works for me. Object required is a pretty generic error just as the "Object reference not set to an..." in .Net. It could be because of wrong syntax in javascript or html that you might have on the page.

If you don't mind pasting the code on the forum please do so we can look at it.


Just tried it and same error.

here is the code:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Index.aspx.vb" Inherits="Index" %>

<!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 id="Head1" runat="server">
<title>Search</title>
<link href="http://links.10026.com/?link=Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<atlas:ScriptManager EnablePartialRendering="true" ID="atlas1" runat="server" EnableViewState="true" />
<form id="frm1" runat="server">

<atlas:UpdateProgress ID="up11" runat="server" >
<ProgressTemplate >
<table>
<tr>
<th style="color:red">Please wait while your serach results are calculated...</th>
</tr>
<tr>
<td>
<img src="http://pics.10026.com/?src=images/spinner.gif" /></td>
</tr>
</table>

</ProgressTemplate>
</atlas:UpdateProgress>
<atlas:UpdatePanel ID="up1" Mode="conditional" runat="server" >
<ContentTemplate >



<table>
<tr>
<th>A word or phrase in the file: </th><td><asp:TextBox ID="txtsearch" runat="server" /></td>
</tr>
<tr>
<th>All or part of filename: </th><td><asp:TextBox ID="txtfilename" runat="server" /></td>
</tr>
<tr>
<th>When was it modified?:</th>
<td>
<asp:DropDownList ID="lstDuration" runat="server">
<asp:ListItem Text="Don't remember" Value="0" />
<asp:ListItem Text="Within the last week" Value="7" />
<asp:ListItem Text="Past Month" Value="30" />
<asp:ListItem Text="Within the past year" Value="365" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2"><asp:Button ID="btnSubmit" runat="server" Text="Search" /></td>
</tr>
</table>

<asp:GridView ID="grdResults" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AllowSorting="True" AllowPaging="True" PageSize="2" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Document Information">
<ItemTemplate>
<p>
<a href="http://links.10026.com/?link=<%# DataBinder.Eval(Container, "DataItem.path")%>">
<%# DataBinder.Eval(Container, "DataItem.Path")%>
</a>
<br />
<i>Last modified:
<%# DataBinder.Eval(Container, "DataItem.Write")%>
</i>
<br />
</p>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

</ContentTemplate>

</atlas:UpdatePanel>
</form>
</body>
</html>

Code behind:

Partial Class Index
Inherits System.Web.UI.Page

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click


' Bind DataGrid to the DataSet. DataGrid is the ID for the
' DataGrid control in the HTML section.
Dim source As New DataView(createDS.Tables(0))
grdResults.DataSource = source
grdResults.DataBind()

End Sub
Private Function createDS() As DataSet
Dim cnnOledb As New OleDb.OleDbConnection
Dim strQuery As String

Dim critstr As String = "(contains(filename,'.doc OR .xls OR .ppt OR .asp OR .aspx OR .txt'))"

If txtsearch.Text.Length <> 0 Then
critstr += " AND (contains(contents,'" + condition(txtsearch.Text) + "'))"
End If


strQuery = "Select DocTitle,Filename,VPath,Rank,Characterization,Write,path from SCOPE() where " + critstr + " order by write desc"

Dim connString As String = "Provider=MSIDXS;Data Source='o drive'"

Dim cn As New System.Data.OleDb.OleDbConnection(connString)
Dim cmd As New System.Data.OleDb.OleDbDataAdapter(strQuery, cn)
Dim objDS As New DataSet

cmd.Fill(objDS)

Return objDS
End Function

Function condition(ByVal srchstr As String) As String
Dim arr As String() = srchstr.Split(" ")
For i As Integer = 0 To arr.Length - 1
Dim str1 As String = arr(i)
If str1 <> "AND" And str1 <> "OR" And str1 <> "NOT" Then
arr(i) = "\" + str1 + "\"
End If
Next
Return String.Join(" AND ", arr)
End Function


Sub grdResults_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdResults.PageIndexChanging
grdResults.PageIndex = e.NewPageIndex
Dim source As New DataView(createDS.Tables(0))
grdResults.DataSource = source
grdResults.DataBind()

End Sub
End Class


Hi again,

I tried this out and I'm getting the same error. This turns out to be a known bug in the April CTP of Atlas. To work around it, add this code to your Page's Load event handler:

Page.ClientScript.GetPostBackEventReference(this, String.Empty);

Thanks,

Eilon


that works. Thank you. btw ATLAS ROCKS!!

Appears to be an issue in the June CTP too... and if it wasn't for this post, I'd still have the issue.

Thanks guys


Correct, this was not fixed in the June CTP. For now the one line workaround should still be sufficient.

Thanks,

Eilon


In the case of nested UserControls, does this workaround apply? If so, where should the workaround go?

I have a page which contains a UserControl, which in turn contains another UserControl, which contains a GridView wrapped in an UpdatePanel. I tried adding this line to the page's Page_Load and the UserControl's Page_Load, but I get the same generic error:

Line: 10846
Char: 17
Error: Object required
FYI, the offending line appears to be the second one pasted below:

function destroyTree(element, markupContext) {

if (element.nodeType == 1) {


Any ideas?

slp004, can you please give more details as to what you're trying to do? It sounds like other people on this thread have this scenario working so I'm curious what's going on here.

Thanks,
Eilon


I was never able to figure out exactly what the problem was, but by breaking the page up into a number of smaller pages sharing a single master page it started working again. There were just way too many UserControls inside GridView inside FormView inside UserControls inside View areas inside show/hide panels... you get the idea.

I have exactly the same problem - in the same line

 function destroyTree(element, markupContext) {if (element.nodeType == 1) {

My page have three or four levels of nested user controls inside the update panel. The curious thing is the page with the same controls has worked before some change I did - now I am trying to figure it out.


Wow, I figured out the issue.

The error was caused because I have another updatepanel in this page - inside a user control, included in master page. The user control has Visible=false. This scenario causes the error. When I set the user control visibility to true, the error goes off.

The solution is setting the updatepanel (that is inside the user control) mode to Conditional. This solves the problem even if the user control is invisible.

HTH.


I had the same problem and I set all the update panels to conditional and it worked.

Paging inside popup

First of all, congratulations for the good job done so far with atlas control toolkit.

Going strict, i have this on my code:

<UpdatePanel>
<page stuf... grids, buttons, etc... />
<Panel (for modal popup)>
<textbox to receive result from popup />
<button to involke popup />
</Panel (for modal popup>
<Panel (for popup)>
<GridView with paging />
</Panel (for popup)>
<UpdatePanel
everything is working just perfectly, but when page changes and DataBind is involked page reloads and go out of modal mode.

Paging is working... if i browse into the textbox that involkes the popup, the grid inside is in new page.

I've browsed this forum for answers but haven't found so far...

Regards

Any ideas? cause i got none :)

Regards,

Felipe Oquendo
MCAD


I'll try to be more specific.

if i have a gridview inside a popup and this popup inside a modal popup, can i use paging for gridview? cause when i do it, the whole page reloads and modal state goes off...

Regards,

Felipe Oquendo
MCAD


I think it is because the elements inside the update panel is refreshing. I would try changing the position of the update panel like so:

<asp:panel id="modalpopup" runat="server">

<atlas:updatepanel id="p1" runat="server">

<your grid here>

<your paging controls here>

</atlas:updatepanel>

</asp:panel>

You have the update panel wrapping everything, including the popup panel, if I'm not mistaken. Only wrap what needs updating via postback (like the gridview and the buttons)

You can even break out your paging buttons into their own update panels and use trigger on the gridview update panel.


I just posted that i didn't have a solution in another thread but BANG! it worked...

I'll need to study the engine i guess... the development is not yet that transparent and the concepts are not well defined...

Paging Problem in Dynamically added GridView

Hi

I am developing a composite control which includes a GridView. GridView is created and bound in CreateChildControls() method. Normally the control works greate. But if I set AllowPaging=True, it gives an "Object null reference exception". Following is the code. Please give me a solution. [N:B: I have added the PageIndexChages Event also].

protected override void CreateChildControls(){_lsAjaxGridView =new GridView();_lsAjaxGridView.ID ="Leadsoft_AjaxGrid";_lsAjaxGridView.AutoGenerateColumns =this.AutoGenerateColumns;foreach (DataControlField dataControlFieldin Columns) _lsAjaxGridView.Columns.Add(dataControlField);if (this.AllowPaging){if (this.PageSize > 0) _lsAjaxGridView.PageSize =this.PageSize; _lsAjaxGridView.AllowPaging =this.AllowPaging; _lsAjaxGridView.PageIndexChanging +=new GridViewPageEventHandler(Leadsoft_AjaxGrid_PageIndexChanged);}_lsAjaxGridView.DataSource = LSDataSourceView;_lsAjaxGridView.DataBind();}
The exception occurs in "_lsAjaxGridView.DataBind();" only when AllowPaging is True.
Exception Message:"Object reference not set to an instance of an object."

Hi this problem is solved. thing is any DataBinding should be done after the control is added to the form.

lsAjaxGridView.DataSource = LSDataSourceView;

Controls.Add(lsAjaxGridView);
_lsAjaxGridView.DataBind();

Paging Sample

Hi there. Here there is an absolute newbie to Ajax. I'm looking for an Ajax sample for gridview/datagrid paging. Where can i find a -closed- sample?

Thanks in advance.

There is no difference to implement asp:GridView paging?between?asp.net?2.0?and?Ajax.Here?are?some?sample?codes?for?your?reference.
<div>
<asp:UpdatePanel ID="pnlGuestbook" runat="server">
<ContentTemplate>
<asp:GridView ID="gvGuestBook" Width="250" CssClass="NotifyTable" DataSourceID="SqlDataSource2" PageSize="2" AllowPaging="True" runat="server" AutoGenerateColumns="False" DataKeyNames="Message_ID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td><br />
<%#Eval("Subject")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" >
<ItemStyle VerticalAlign="Top" />
</asp:CommandField>
</Columns>
<PagerSettings Mode="NumericFirstLast" FirstPageText="First" NextPageText="Next" LastPageText="Last" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProductConnectionString %>"
SelectCommand="SELECT [Message_ID], [From], [Subject], [DateSent] FROM [Message]">
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gvGuestBook" EventName="PageIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
Wish this can help you.
Thank you. It was so simple. Just drag and drop two controls (ScriptManager and UpdatePanel) and put GridView in UpdatePanel. Love it. =)

Paging using DataGrid and DataList (referring to ScottGus paging tutorial)

I have a webpage that uses a Datalist adapted from ScottGu's example athttp://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx. It does not seem to benefit from Ajax partial updates (update panel), since as it pages, it actually asks for different pages' urls, etc...(Please see ScottGu's fantastic tutorial there for more details).

Question: If I use a DataGrid that has paging turned on, will it (magically) perform the operations mentioned in Scott's article, that is, sending only that data through each page request that is pertinet to that page?

Question 2 There is a slim chance that ASP.Net Ajax is actually so smart as to do what I said above, however, I need a DataList (for formatting reasons) that does not have paging .

Is there a way for the paging mentioned in ScottGu's article to be applied to the asynchornous paging, and for the paging control on the page (a hyperlink) to fetch data from that stored "stash"?

Thanks,

Paolo

Dogs Rule!

Just glancing through Scott's post, it doesn't look like this will "just work" inside an UpdatePanel, because as you mention, it's requesting a new page URL with the page number in the query string.

To get something like this to work, you'd need to first convert it to use postbacks instead of page navigation. (So change the hyperlink to a HyperLinkButton and pass the page number as an argument to the event handler instead of as a query string parameter.)

Basically, if you have a page that works with postbacks, it should be easy to use UpdatePanels to get AJAX functionality. If you have navigation, however (new URLs), then the UpdatePanel won't help you.


View this code

CODE
Sub BindData()
Dim mydt As New yourdatable()
Dim tba As NewyourobjectTableAdapters.yourtableadaper()


tba.Fill(mydt, Me
dgPager.CurrentPageIndex * Me.dgPager.PageSize , Me.dgPager.PageSize)

Me.dgPager.VirtualItemCount = yourqueryrecordcount

Me.
dgPager.DataSource = mydt
Me.
dgPager.DataBind()

Me.DataList1.DataSource = mydt
Me.DataList1.DataBind()

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
BindData()

End If
End Sub

Protected Sub dgPager_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Visible = False
End If

End Sub

ProtectedSub dgPager_PageIndexChanged(ByVal source As Object, ByVal e AsSystem.Web.UI.WebControls.DataGridPageChangedEventArgs)
Me.dgPager.CurrentPageIndex = e.NewPageIndex
BindData()

End Sub
ASPX page

<form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal">
<ItemTemplate>
<%# Eval("YourDataField") %><br />
</ItemTemplate>
</asp:DataList>
<asp:DataGridID="dgPager" runat="server" AllowPaging="True"AutoGenerateColumns="False" GridLines="None" PageSize="8"ShowHeader="False" OnPageIndexChanged="dgPager_PageIndexChanged"OnItemCreated="dgPager_ItemCreated" AllowCustomPaging="True">
<PagerStyle Mode="NumericPages" />
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

</form>