Solved

How to call an update SQL Stored procedure from aspButton click and without postbacks

Posted on 2013-02-06
7
328 Views
Last Modified: 2013-02-11
Hello EE,

i have a asp grid view in my webForm and in it I have a ItemTemplate of a checkBox.

if user select lets say Row 1, 6, 7 and 10. then presses a asp:button (that is not in the grid, its rght up front of it) I need to call  a UPDATE SQL stored proc but my problem is I know the OnClick will do a postback and all my dropDown in my webForm will reset and user will need to get back to values he wanted.

actually, those dropdowns are search options and when click search, it populates the grid based on down selectedValues you know.


how can I do?  or maybe I need to save all selcetedvalues somewhere then do the onClick with a postback and call another function that refill everyhing?

I dont know im lost.. any ideas with examples?
0
Comment
Question by:PhilippeRenaud
7 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 38861165
Just add an update panel.

<asp:UpdatePanel runat="server" ID="updatePanel1">
<ContentTemplate>
   <yourGrid>
<your button>
</ContentTemplate>
</asp:UpdatePanel>

On the button click the grid shouldn't refresh
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 38861178
but what about my other controls on the page ?
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 38861360
ahhh ok I understand know.. I should just put ALL the damn thing in the contentTemplate...just in case.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 26

Expert Comment

by:Alan Warren
ID: 38861559
Do you have viewstate enabled for "those dropdowns" and the GridView?
They should maintain state if ViewState is enabled, unless you are programmatically populating your GridView on page load, in which case you could wrap the code that programmatically populates the Gridview in an If not page ispostback then block, so it only fires the first time the page is loaded, then the controls should maintain state through a postback.


Alan
0
 
LVL 10

Expert Comment

by:Monica P
ID: 38862943
using jquery AJAX webmethod call u can make server side code to get called.

http://deebujacob.blogspot.com/2012/01/aspnet-ajax-web-method-call-using.html
0
 
LVL 3

Accepted Solution

by:
AshwaniMunshi earned 500 total points
ID: 38863031
You can refer following article to calling methods using jquery-Ajax
http://www.codeproject.com/Articles/224827/Jquery-Ajax-Calling-functions

If you want to go with Update panel approach, then refer following article:
http://stackoverflow.com/questions/9257581/using-gridview-inside-updatepanel
0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 38876253
thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now