Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-02-06
7
329 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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