.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Formview paging not working with objectdatasource and viewstate setup

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

I was able to get the formview bound to the objectdatasource, it works great for the first record, but when i select the next record it gives me error  below is all my code, if there is something else that i need to post please let me know.


I opt'd for using formview since it has paging ability.. But now that i got that working, selecting the next record gives me an error.

This is what i have as my button event:


        protected void btnSearchHealthRecords_Click(object sender, EventArgs e)
            if (ddlVehNum.SelectedValue == "0")
                rfvVehNum.IsValid = false;
                ObjectDataSource1.SelectMethod = "HealthRecords";
                ObjectDataSource1.SelectParameters.Add("vehiclenum", TypeCode.String, ddlVehNum.SelectedValue.ToString());

                ViewState["MethodName"] = "HealthRecords";

                FormView1.Visible = true;

                Session["btClick"] = "5";
                sn.Visible = true;


        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)

View Complete Post

More Related Resource Links

DataGrid Paging not working

I got DataGrid Paging functionality on, I can see the paging 1,2,3,4,5.... but when i try to click on it to go to that page the datagrid just goes blank (does not render any record anything). My code is below: <asp:DataGrid ID="dgArticles" AllowPaging="true" Width="100%" AllowSorting="True" AutoGenerateColumns="False" runat="server" OnPageIndexChanged="dgArticles_PageIndexChanged" PageSize="15" EnableViewState= "true"> <ItemStyle Font-Names="Arial" Font-Size="12px" /> <HeaderStyle Font-Bold="true" ForeColor="#FFFFFF" Font-Names="Arial" Font-Size="14px" BackColor="#B2C1D1" /> <PagerStyle Mode="NumericPages" CssClass="FooterButton" Font-Size="Large" /> <AlternatingItemStyle BackColor="#EAEAEA" /> <Columns> <asp:BoundColumn DataField="ContentID" HeaderText="Content ID" /> <asp:HyperLinkColumn DataTextField="Headline" DataNavigateUrlField="ContentID" DataNavigateUrlFormatString=

AJAX call is not working on F5 load balancer web farm setup

I have the following web farm setup in production server.Browser --> HTTPS --> Load Balancer --> HTTP --> webserver nodeF5 Load balancer handles off box SSL termination. It implies that SSL resides on F5 load balancer. Problem Statement: Ajax calls do not go through unless "Access data sources across domains" option is enabled in IE security settings. I have the similar setup in staging server except F5 Load balancer. The ASP.Net application makes perfect AJAX calls on both HTTP and HTTPS.However, the staging server web farm use windows NLB and SSL resides on individual web server nodes

Change password for FBA users in claims setup not working as expected

Hi, I am trying to add a standard asp:changepassword control for external users. In the previous 2007 sharepoint environment this control was working "out of the box". I am pretty sure what is wrong as well,- but not sure how to fix it. A workaround that makes me able to change password is as follows: in the asp - control, I have added the option DisplayUserName="true" Then in the actual web-page, i can see that my username is: 0#.f|acaspnetsqlmembershipprovider|xxxxxx and not xxxxxx as i would excpect, as i use xxxxxx to log in. Editing the username to just xxxxxx makes the changing of password work, but this solution is not really nice to deploy to the normal end-users.. Any suggestion on how to make the username right? I've tried to set the username using the option UserName="<%=SPContext.Current.Web.CurrentUser.LoginName%>", but it does not seem to evaluate..  

ViewState Not Working With ColorPickerExtender

 I've got an ASP.NET 3.5 page with multiple ColorPickerExtender controls on it. The functionality works fine in that the selected color is displayed on the associated panel and text boxes, but when a postback is performed from a drop down list on the page, the colors are always reset to their initial values when the page was loaded.

Gridview Objectdatasource calling funtion while paging

Hi,I am asking this question in bit confused state..I have a Gridview in a page which is bind to function via ObjectDataSource. Function returns dataset. I am returning dataset becuase its disconnected...but when navigating/ or using paging the see a call to the function again.. why is that? if dataset already has data then why it needs to go and make a call to DB again? please explainThanks

How to handle sorting and paging when objectdatasource is being built dynamically?

i am building my objectdatasource dynmically when certain buttons are clicked on the page.. and with that the gridview is being displayed with the results of the objectdatasource that was built. So my gridview code looks like this: <asp:GridView ID="GridView1" runat="server" Visible="False" Width="85%"> <EmptyDataTemplate> There are no results for your search. Please try again. </EmptyDataTemplate> </asp:GridView> How can i enable sorting and paging if the datasource is being built on button click event?

Is it possible to store objectdatasource in session or viewstate to use on another page?

Im building my objectdatasource on different button events.. so id like to know if i can store that or the results in a session or viewstate so i can use it on a pop-up window. explanation: User arrives at our page. They select or enter specific information to search.. results found are presented in a gridview, that is currently bound to the objectdatasource. Within that gridview i will be adding a button to open a new window that will display a googlemap with the location marked on the map. Also will be adding a button to view all the results on the map. So if your search returns 10 records and you want to see all 10 marked on the map, they can click the "View All" button and they are all marked on the map.. Or if you want to just view 1 at a time, you select that record and it display just that record on the map.   So not sure what i should do to accomplish this.

FBA zone setup not working

I'm trying to implement an extranet site to give FBA access to some users who aren't going to be setup in AD. I followed the guide at http://msdn.microsoft.com/en-us/library/bb975136.aspx but I'm having problems trying to get the users setup for the extranet site. When I add try to add the membership and role codes to the web.config for the Central Admin I can't log into the Central Admin until I removed them from the web.config or at least removed the defualt provider label but then I can't get a user validation for the Policy for Web Application > Add Users page.

AsyncFileUpload inside FormView not working

I'm having a lot of problems with something seemingly simple, and from other posts sounds like people have been able to do. I have a FormView inside a user control, and in the InsertItemTemplate, I have an AsyncFileUpload control, that I would like to to use. On the user side, it seems to work, but it doesn't work on the server side code behind. The HasFile Property is always false, and it doesn't fire the UploadCompleted event either. My UpdatePanel is in the master page. Any ideas? Thanks <asp:FormView ID="frmAddImage" runat="server" DataKeyNames="imageID" DataSourceID="sqlImages" Width="100%"> <InsertItemTemplate> <cc1:AsyncFileUpload runat="server" ID="FileUploadImage" Width="400px" UploaderStyle="Traditional" CompleteBackColor="Lime" ErrorBackColor="Red" onuploadedcomplete="AsyncFileUpload_UploadedComplete" UploadingBackColor="#CCFFFF" />  

textchange event not working from textbox on formview


Hello guys.  I have a formview which in insertmode is required to assign a value to a textbox from another on textchange event.  I can't get it working.

here's formview code (in bold:  event call:

<asp:FormView ID="fvPrecios" runat="server" AllowPaging="True" DataSourceID="OdsPrecios"
        Style="position: relative" CellPadding="4" ForeColor="#333333"
        DataKeyNames="precnume" >
            <table style="position: relative" width="400">
                    <td style="width: 62px; height: 26px">
                        <asp:Label ID="lblEditNombre" runat="server" Text

SPGridView grouping not working with sorting or paging


Anybody can help with the issue here? I have a SPGridView using ObjectDataSource with grouping, sorting and paging enabled. Once i clicked on the next button or the sort header, it's give the "An unexpected error has occurred." on screen. 

Error in the 12 hive logs
Application error when access /Web Pages/TestGridView.aspx, Error=Value cannot be null.  Parameter name: container
at System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName)
at Microsoft.SharePoint.WebControls.SPGridView.OnRowCreated(GridViewRowEventArgs args)
at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource)
at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
at Microsoft.SharePoint.WebControls.SPGridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()

Paging not working with two controls- Dropdownlist & Listview


So I am using EW + Access database to create a page.

This page contains two controls. First control is Dropdownlist which databinds with second control Listview.

This listview has paging on becuse of multiple pages. If I don't use QueryStringField paging works but if I use QueryStringField paging doesn't work and it goes back to first option of Dropdownlist.

I need paging to access specific records.

Can anybody help me with this issue.

Thx in advance!!

SQL Server 2008 R2 Setup has stopped working


Hi, I have a server with Windows Server 2008 R2 Standard Edition English and when I try to install SQL Server 2008 R2 Standard Spanish the installer give to me:

"SQL Server 2008 R2 Setup has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

Previously I changed the Current Format in Regional and Language Options to Spanish to solve a problem with OS Local. The mentioned error appears during the step of install the Setup Support Files, the step stop and show me the error with a "Close program" button, after press the button the installation finish. Thanks in advance.

DELL PowerEdge T710
2 Intel Xeon CPU E5502 1.87GHz

Windows Server 2008 R2 Standard 64bit ENU (english)
SQL Server 2008 R2 Standard 64bit ESN (spanish)

FormView + ObjectDataSource - can't find ControlParameter values


I'm trying to use a FormView + ObjectDataSource that uses ControlParameters to do an insert.

I have the following static DAL method which calls my LINQ-to-SQL stored proc:

public static void AddQuestion(string questionText, string expectedAnswer, bool alwaysShow, int interviewTypeID, int skillFamilyID, int questionSubcategoryID, int competencyTypeID)
using(ACITDataContext db = new ACITDataContext())
db.usp_AddQuestion(questionText, expectedAnswer,
alwaysShow, interviewTypeID, skillFamilyID,
questionSubcategoryID, competencyTypeID);
catch (Exception ex)
throw (ex);

And I have this WebForm page (some content removed for brevity):

<asp:FormView ID="frmQuestion" runat="server" DefaultMode="Ins

Installing a certificate in the Commit() of a setup/deployment project not working


I'm trying to create a deployment project for a client application that uses certificates for WCF. I've followed this


and I can get that to work, but when I add in my own code to install the certificates it does not work.

Here is the code I've have:

public override void Commit(IDictionary savedState)
		Console.WriteLine("Installing certificates...");

Enabling Paging on ObjectDataSource that is built dynamically in code behind


I have the following on my aspx page

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="DataAccessCode" SelectMethod="SelectDVRInfo" OnSelected="ObjectDataSource1_Selected">

Then in my code behind i have the following set up in 4+ button events, since each button serves a different purpose.. Prior to this past week, i was only working with 2 gridviews on the page.. that were linked to this datasource.. so everything was fine.. but recently had to add a Datalist to display the results a certain way.. I got it all working, but now that more records are in the table the datalist is growing in length on the page and cant figure out how to modify the current code to enable paging without having to redesign the logic all together to get it enabled.

Based on what i have below and above, is there a solution i can implement to implement paging ONLY for the Datalist? Or if it cant be specific, if enabled, will it affect the gridview that is already configured to enable paging, which already works?


                ObjectDataSource1.SelectMethod = "SelectDVRInfo";

Viewstate is not working in Radiobutton and Checkbox


Hi ,

The above question is my problem,Can any one expalin what is viewsate and from your point with a nice and simple example. thanks

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend