C# - Grid Data Bound To Stored Procedure Getting Called Multiple Times?

Mar 8, 2011

I have an application that uses an aps:GridView. The GridView is populated using a DataSource that calls a Stored Procedure. The DataSource passes parameters to the Stored Procedure based on some text fields. The page has been running slower than wanted, so I was doing some checking.

I ran SQL Profiler while loading the page, and saw the Stored Procedure was being called twice. I stepped through the code and found out that in the Page Load Complete event was where this was happening. In this event, I set the value of a parameter for the Stored Procedure, then did a DataBind on the GridView to pick up the data. As I was stepping through the code, I watched the SQL Profiler. When I got to the step of setting the parameter, the Stored Procedure had not yet been called. When I stepped through that and got to the DataBind command (before running that step), the SQL Profiler showed that the Stored Procedure had been called. Then I did the DataBind and the StoredProcedure was called again.

My question is, how do I get the parameters set, and get the GridView data bound, and only call the StoredProcedure once? If I comment out the DataBind step, the StoredProcedure never does get called (which seems really strange to me...).

View 1 Replies

Similar Messages:

Best Way To Insert Values Multiple Times From Data Layer To Stored Procedure?

Feb 16, 2011

I have DAL Layer, from where invoking a stored procedure to insert values into the table.



Now as requirement changed, per client request i have to add values 5 times. So what is the best practice?

Do i call this Stored Procedure 5 times from my DAL?

View 4 Replies

SelectMethod In ObjectDatasource Getting Called Multiple Times With Multiple Datapagerfield?

Oct 7, 2010

so here is the setup. I am building a page that has a listview, a datapager, and 3 datapagerfield (2 x NextPreviousPagerField, 1 x NumericPagerField), and a objectdatasource to tide all of this together.

It was all working fine until I put a breakpoint into the SelectMethod specified in the objectdatsource control. It seems like that for each datapagerfield control, it is calling the selectmethod and selectcount method. Hence, whenever a user paged, it calls the database 6 times instead of 2 (I don't have caching turned on atm). If I remove one datapagerfield, it will remove 2 calls.

Now this is build in asp.net 3.5 SP1 in VS2008. When I copied the same code files to a asp.net 4.0 VS2010 solution, it duplicate call seems to be gone.

Is this a bug in asp.net 3.5 SP1?

View 1 Replies

Forms Data Controls :: Have A Gridview In Aspx Page Bound To A Stored Procedure?

Dec 7, 2010

I have a gridview in aspx page bound to a stored procedure, and data is loaded from the database. I have 2 problems which I am banging my head against. 1. Stored Proc has default values of NULL ( which is a DateTime db type) and I don't get how to give them as default values and once I have valid date time ( from textbox on form) , I need stored proc to take this value . ( I have done this from server side code but if this is able to acheive from client side that would be great.

2. As shown below my gird view is present ( no columns are bound and since the data is loading from server side ) I am unable to do sorting on the gridview without a sort expression. Does any one know how to do this?? This is my biggest concern. I have checekd all the articles I could find on google


View 5 Replies

MVC :: Initialize Method Called Multiple Times?

Jul 6, 2010

I'm overriding the Controller.Initialize method to set some stuff before each ActionResult is executed, however I'm finding that the method is being called multiple times for each request (anywhere between 2 - 10 times). I'm running in Cassini.

My hunch is that it is running for all static files (images, css etc) as well as the requested action - although I may be wrong? I thought maybe something was wrong in my web.config but it all looks right to me.

View 6 Replies

MVC :: Application_start Event Called Multiple Times In Application

Sep 15, 2010

In my MVC application ,I am updating my web.config at runtime through application_start event.So, ideally it should be done only when the application is started.BUT in MY mvc application the application_start event of global.asax is being called multiple
times , even when i have not restarted the application.

Its being repetadly called when i am calling different actions , so the webconfig is repetedly updating & making my application very very slow. what's the reason & how to handle this .

View 2 Replies

ADO.NET :: Calling Stored Procedure : Server Times Out

Aug 4, 2010

So I just attempted to call a stored procedure from my VB code. Here is the code-behind function that is called to handle this:


And here is the Stored Procedure:


Then when I run this, I get an error that the server timed out. Without calling this function to reference the stored procedure, the application runs well, users can log in/create accounts, etc. But something in the function and/or the stored procedure is timing out.

View 13 Replies

DataSource Controls :: How To Find Stored Procedure From Which This Is Called

May 19, 2010

There is one sp(1) which is called from another sp(2)How can I find from which sp it is called.

View 2 Replies

MVC :: Stored Procedure To Display Data In Jquery Grid?

Mar 30, 2010

am using asp.net mvc.. i have db2 database with one table..... i have a stroed procedure with input parmater as useridi need to pass userid to get all the results from table to display in jquery grid on UIplease

View 4 Replies

ADO.NET :: Select Stored Procedure Called By LINQ In Entity Framework?

Jan 6, 2011

I have a stored procedure that receives 2 parameters and returns 3 columns.

Here is how I added the SP:

1. Added SP to entity model (.edmx) via update model from DB.

2. Did a Function Import -- selected my SP, clicked "Get Column Information" and then created a new complex type (myStoredProcedureName_Result) which I assigned.

3. My LINQ is the following:


View 3 Replies

DataSource Controls :: Get The @@Identity From A Table By Using A Stored Procedure Called By Website

Jul 10, 2010

I am trying to get the @@Identity from a table by using a stored procedure called by my asp.net website. I am using a datareader to do this but get an error as it tells me it cannot convert the returned value to getint. Here is my code. What should I be using instead of getint?

Dim myReader = cmd.ExecuteReader()
While (myReader.Read())
intID = myReader.GetInt32(0)
End While

View 3 Replies

Web Forms :: Choosing Return Type When Stored Procedure Is Called From Entity Framework

Sep 16, 2012

I have a stored procedure in SQl and i am calling through Entity framework through import functions. Stored procedure is returns columns from 2 different tables.. now what should be return type at Entity framwork end ?

View 1 Replies

Forms Data Controls :: Dynamically Bind Grid Then Send To Stored Procedure?

Jan 11, 2011

I am looking to have 1 Gridview/Datagrid (which ever is now more appropriate) on my code in front,

the columns will need to be dynamically generated, with a "Always present" checkbox control with the default being checked

Each column will be a Label type - so not editable

The Idea is the user will tick or until each item that they wish to submit to the database.

I am able to dynamically populate the control - using new bouncontol, but I have been unable to then obtain the selected data.

My codebehind is below



View 3 Replies

Forms Data Controls :: What's The Best Grid Control For Paging Without Creating A Stored Procedure

Jan 6, 2011

I have been using the GridView control, to display data, but now my two datasources (Informix, and VisualM/Mumps) makes it very difficult to create a store procedure to with paging. Is there a better data grid, that will allow my users to scroll/search the current data set?

View 1 Replies

Web Forms :: Allow User To Enter Data On A Grid Page If There Is No Data On A Field Of A Stored Procedure?

May 26, 2010

I have a grid page which has a datasource as a stored procedure. The grid page shows the fields obtained after executing the stored procedure.Now, there is a field called 'PURCHASE PRICE' on the stored procedure which can have empty values.If the grid page have that field empty, it should appear as the text box so that the users can enter some numeric values and run the page.

View 1 Replies

C# - Is A Variable Stored In Session Deserialized Once Or Multiple Times Throughout A Page Lifecycle

Jan 27, 2010

I would like to wrap Session variables in a manner similar to that discussed on CodeProject.


Here is my question: if I have to access CurrentUser multiple times in the same page, would I get a performance improvement by assigning it to a local variable instead of accessing the wrapping property? Or does the HttpSessionState make sure the object is only deserialized once per request, so that subsequent calls in the same http request don't cost any more?

View 4 Replies

Data Controls :: Need A Stored Procedure To Fetch Combined Data From Multiple Tables

Dec 27, 2012

i have a details table which include detailid, custname, address, classification , pincode, telephone, remarks and classification table contain classification id & classification.i want to insert detailid & corresponding classificationid to a new table detail_classification. How to write stored procedure for that?

View 1 Replies

Data Access Strategy For Single Stored Procedure Retuning Multiple Recordsets In Webpage?

Sep 18, 2010

what is the recommended data access strategy for the following environment: single stored procedure, many parameters, asp.net 4.0, sql server 2008, and the stored proc returns 11 different recordsets, all of which get displayed in various different elements too complex and specific to be handled by server controls.

View 1 Replies

DataSource Controls :: How To Convert The Oracle Stored Procedure To Sqlserver 2005 Stored Procedure

Apr 2, 2010

This is surareddy. i nead some small clarification in the "Stored Procedure"

how to convert the oracle Stored Procedure to sqlserver2005/2008 Stored Procedure.

right now i am enhancing the project that project already developed the oracle Stored Procedure. now our company is using sqlserver 2005/2008.

how to convert the Oracle Stored Procedure to sqlserver 2005 Stored Procedure

View 4 Replies

DataSource Controls :: Do Not Use Or Call Any Stored Procedure But It Says "Could Not Find Stored Procedure 'xxxxx'?

Dec 9, 2010

Initially, I have tried to use stored procedure. But I changed my mind and preferred to call sql query in codebase with command text. However, it stills tries to find initially-called stored procedure (which is neither called or exists).I think that it is related caching. But I tried it with different browsers it did not work.What might be the reason?

View 4 Replies

ADO.NET :: Stored Procedure Returning Multiple Ref Cursors

Nov 22, 2010

Is it possible to have a stored procedure return multiple ref cursors to a .Net application? I tried this, but it didn't work.

While odr.Read()
dtUserData.Load(odr, LoadOption.OverwriteChanges)
End While
While odr.Read()
dtUserRoles.Load(odr, LoadOption.OverwriteChanges)
End While

View 1 Replies

SQL Server :: Stored Procedure With Multiple Parameters?

Nov 28, 2010

I have a table with 4 columns.The first column is a list of teams.The other three columns specify whether the team member with the particular id is present on any particular day .Say for example in the third row the running Team has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.I have a Query like this

Select Teamname from tblTeam where Running not like '%|2|%' and Running not like '%|3|%' and Running not like '%|7|%' and Biking not like '%|1|%' and Biking not like '%|4|%' and Biking not like '%|7|%' and shooting not like '%|3|%' and shooting not like '%|4|%' and shooting not like '%|7|%' Basically i am searching the columns with like clause.The search criteria for each column may vary.In the above query i am searching for Teams where Running column does not contain 2,3 and 7,Biking column does not contain 1,4 and 7 and the shooting column does not contain 3,4 and 7. I would like to set a stored procedure where i would be able to pass 3 set of parameters from the code behind(I am using VB.net) for Running column search,Biking column search and the shooting column search.

Can someone tell me writing a simple stored procedure.I have a table with 4 columns.The first column is list of teams.The other three columns specify whether the team member with the particular id is present or not on any particular day .Say for example in the third row the running column has 2 and 3 which means team member with the id 2 and 3 are present.Multiple values are seperated by the pipe symbol '|'.

View 13 Replies

SQL Server :: Search Multiple Tables Via Stored Procedure?

Jul 27, 2010

I'm a novice in .NET programming. I was trying to figure a way to make a MULTI TABLE search via a stored procedure for my website. I've written a SP to select records from one table, which isn't working for some unknown reasons:


Whatever I search for, the datagrid is displaying all records from my table.

View 5 Replies

Web Forms :: Update Multiple Records Using Stored Procedure

May 7, 2015

I get the fol error: An exception of type 'System.Data.SqlClient.SqlException' Occurred in System.Data.dll but was not handled in user code..Subquery returned more than 1 value. This is not permitted When the subquery Follows =,! =, <, <=,>,> = Or When the subquery is used as an expression.

IF EXISTS (SELECT CustomerId FROM Customers where CustomerId= (SELECT Id FROM @tblCustomers ))
UPDATE Customers
SET Name=(SELECT Name FROM @tblCustomers ), Country=(SELECT Country FROM @tblCustomers )
WHERE CustomerId=(SELECT Id FROM @tblCustomers );


View 1 Replies

Submit Repeating / Multiple Items To Stored Procedure Via Webservice

Mar 7, 2010

I am trying to what i think is an easy task, but so far i have came up empty.

What i want to do is take a repeating table on a form i have and submit the employee IDs to a database using a web service.

I know how to submit them one by one, but i am thinking there is an easier way to do this instead of send the value to the web service, submit thee data, and then go till the last record.

I am currently using this:

<WebMethod(Description:="sends employee id to database")> _
Public Function SendMultiple(ByVal strEmployeeID as string) As String
Dim sqlCon As New SqlConnection()
Dim sqlCmd As New SqlCommand()
sqlCon.ConnectionString = "connection string information"
If sqlCon.State = ConnectionState.Closed Then
End If
sqlCmd.CommandText = "spInsertMultiple"
sqlCmd.Connection = sqlCon
sqlCmd.CommandType = CommandType.StoredProcedure
Dim Parameter0 As SqlParameter = New SqlParameter("@EmployeeID", strEmployeeID)
Parameter0.Direction = ParameterDirection.Input
Dim dr As SqlDataReader
dr = sqlCmd.ExecuteScalar
Dim strReturnedValue As String = "hello"
Return strReturnedValue
End Function

View 6 Replies

Copyrights 2005-15 www.BigResource.com, All rights reserved