Solved

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

Posted on 2013-02-06
7
326 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 39

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

19 Experts available now in Live!

Get 1:1 Help Now