473,756 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET,AJAX, SPGridView

7 New Member
I am trying to enclose SPGridView inside an UpdatePanel control in a user control page (.ascx), however whenever I click on the paging links for the grid, it still postbacks instead of partial page rendering. Also, this is not the first time I have used ajax in my project. I have taken the same code that has worked on other controls and applied them to the SPGridvew with no success. Below is a sample of the user control page in question with my override childcontrols. Any thoughts?

Expand|Select|Wrap|Line Numbers
  1. protected override void CreateChildControls()
  2.         {
  3.             // Register the AJAX ScriptManager
  4.             ScriptManager ajaxScriptManager = ScriptManager.GetCurrent(this.Page);
  5.  
  6.             if (ajaxScriptManager == null)
  7.             {
  8.                 ajaxScriptManager = new ScriptManager();
  9.                 ajaxScriptManager.ID = "AJAXScriptManager";
  10.                 ajaxScriptManager.EnablePartialRendering = true;
  11.                 this.Controls.Add(ajaxScriptManager);
  12.             }
  13.  
  14.             EnsureAJAXUpdatePanelCompatibility();
  15.  
  16.             ajaxUpdatePanel = new UpdatePanel();
  17.             ajaxUpdatePanel.ID = "AJAXUpdatePanel";
  18.             ajaxUpdatePanel.ChildrenAsTriggers = true;
  19.             ajaxUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
  20.             this.Controls.Add(ajaxUpdatePanel);
  21.  
  22.             currentSite = SPContext.Current.Web;
  23.  
  24.             using (ListCaml listCaml = new ListCaml(currentSite))
  25.             {
  26.                 searchID = ((SearchLibraryResultsPage)this.Page).searchID;                
  27.                 searchResultInfo = SearchProcessController.GetSearchResultInfo(searchID);
  28.  
  29.                 using (Fields fields = new Fields())
  30.                 {
  31.                     searchResultsInfoArray = fields.CreateStringValueArray(searchResultInfo);
  32.                 }
  33.  
  34.                 elapsedTime = Convert.ToDouble(searchResultsInfoArray[0]);
  35.                 setNumber = Convert.ToInt16(searchResultsInfoArray[1]);
  36.                 rowStart = Convert.ToInt16(searchResultsInfoArray[2]);
  37.                 rowCount = Convert.ToInt16(searchResultsInfoArray[3]);
  38.                 isNextSet = Convert.ToBoolean(searchResultsInfoArray[4]);
  39.                 sortManagedProperty = searchResultsInfoArray[5];
  40.                 sortDirection = searchResultsInfoArray[6];
  41.  
  42.                 searchResultsDT = (DataTable)Cache["SearchResults_" + searchID.ToString()];
  43.                 searchCriteriaDT = (DataTable)Cache["SearchCriteria_" + searchID.ToString()];               
  44.  
  45.                 gridView = new SPGridView();
  46.                 searchResultsDV = new DataView(searchResultsDT);
  47.                 gridView.DataSource = searchResultsDV;             
  48.  
  49.                 //CreateViewColumnMenu();
  50.  
  51.                 searchCriteria = new StringBuilder();
  52.  
  53.                 foreach (DataRow libraryFieldsDR in searchCriteriaDT.Rows)
  54.                 {
  55.                     if (libraryFieldsDR["Value"].ToString() != string.Empty)
  56.                     {
  57.                         CreateSearchCriteriaList(libraryFieldsDR["Column_Name"].ToString(), libraryFieldsDR["Literal_Operator"].ToString(),
  58.                                                  libraryFieldsDR["Data_Type"].ToString(),libraryFieldsDR["Value"].ToString());                       
  59.                     }
  60.  
  61.                     if (libraryFieldsDR["Column_Name"].ToString() != "Path")
  62.                     {
  63.                         SPBoundField boundField = new SPBoundField();
  64.                         boundField.HeaderText = libraryFieldsDR["Column_Name"].ToString();
  65.                         boundField.DataField = libraryFieldsDR["Managed_Property"].ToString();                    
  66.                         boundField.SortExpression = libraryFieldsDR["Managed_Property"].ToString();
  67.                         gridView.Columns.Add(boundField);
  68.                     }
  69.                 }
  70.                 gridView.AutoGenerateColumns = false;
  71.                 gridView.AllowSorting = true;
  72.                 gridView.AllowPaging = true;
  73.                 gridView.PagerSettings.Position = PagerPosition.Top;
  74.                 gridView.PagerSettings.Mode = PagerButtons.NumericFirstLast;
  75.                 gridView.PagerSettings.PageButtonCount = 5;               
  76.                 gridView.PageSize = listCaml.GetSearchResultLimits(Convert.ToInt16(Session["Current_LibraryID"]), SharePointSearch.resultsPerPage);
  77.                 gridView.Sorting += new GridViewSortEventHandler(gridView_Sorting);
  78.                 gridView.PageIndexChanging += new GridViewPageEventHandler(gridView_PageIndexChanging);
  79.  
  80.  
  81.                 ajaxUpdatePanel.ContentTemplateContainer.Controls.Add(gridView);
  82.                 //PagerTemplate must be added after you added the control, but before you bind your data
  83.                 gridView.PagerTemplate = null;
  84.                 gridView.DataBind();
  85.  
  86.                 //AddResultsInformation();
  87.  
  88.                 //Preserves the sorting when page is reload
  89.                 if ((!Page.IsPostBack) && (sortManagedProperty != string.Empty) && (sortDirection != string.Empty))
  90.                 {
  91.                     ViewState["SortExpression"] = sortManagedProperty;
  92.                     ViewState["SortDirection"] = sortDirection;
  93.                     AddSortColumnArrows(gridView.HeaderRow,sortManagedProperty, sortDirection);
  94.                     gridView.DataBind();
  95.                 }
  96.             }
  97.         }
  98.  
Jul 12 '08 #1
1 2715
wagswvu
7 New Member
Well after many of hours messing with this, I decided to just double check that the UpdatePanel was even working. So I added a TextBox and a Button with an EventHandler that would clear the text out of the TextBox. To my amazement, when I added those two controls the SPGridView started working... I did a few more experiments and soon I discovered that by just having a TextBox control visible on the screen would allow the SPGridView to work with the UpdatePanel. Take it off the page and SPGridView is back to full postbacks. I am now completely mystified on what’s going on, anybody have an idea?
Jul 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
2342
by: Yarco | last post by:
I want to use "Ajax" to create my web for hobby. But i don't know whether "Ajax" is mature... And what about with php? Someone have experience on it? ....
4
4326
by: bobzimuta | last post by:
I'm creating a simple AJAX library. It's an object that will return an array containing the response text or xml. I'm trying to find a way to assign the response as a property of the object, but from within an inline function. Within the AJAX object: this.xmlhttp = new XMLHttpRequest(); this.response = ''; //to contain the response text OR xml var that = this; //since we cannot reference this within the
0
1845
by: melledge | last post by:
Ajax Developers' Day added to XTech 2006 agenda XTech 2006 - 17-19 May - Hotel Grand Krasnopolsky - Amsterdam, The Netherlands
0
1840
by: melledge | last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference Industry experts offer insight into next generation of the Web ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the rapidly developing world of Ajax user interfaces on the browser, IDEAlliance (www.idealliance.org) announced today that its annual XTech Conference will kick off on May 16 with Ajax Developers' Day. XTech 2006 (www.xtech-conference.org), to be held May...
1
16512
by: www.web20developers.com | last post by:
http://www.web20developers.com http://www.web20developers.com/index.php?option=com_content&task=view... Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell AJAX - microlink pattern tutorial : A microlink is a link that opens up
10
3073
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's another to really see how great something is.) Thanks -- Share The Knowledge. I need all the help I can get and so do you!
2
2262
by: soni2926 | last post by:
hi, does anyone know of any good books on ajax and asp.net, one that teaches ajax itself before jumping in atlas? I wanted to get an understanding of ajax and how to use it, most books i've seen on .net and ajax seem to jump into atlas right away, does anyone know of any that teach ajax itself and then later get into atlas?
1
3415
by: shaunwo | last post by:
I'm an AJAX / DOM Novice (at best) and trying to figure out how to write the value to a couple input fields. I don't remember exactly where I got the ajax.js file I'm using from (went to the website that I see in the comments, but no luck there), but what I already have works GREAT to populate the options in a select box. Now I'm trying to take that same code and get it to write the value to a couple input boxes. Here's a link to my ajax...
11
3048
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7 and IE8. There is no issue when the controls are allowed to complete loading. Can you please tell me the best practice that handles this? Thanks.
0
10032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5141
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.