im trying to update my database from the checkbox in a grid view. i want to do it using ajax so that the page doesn't have to refresh everytime i click o the checkbox. how am i supposed to do that?
A:
You can use JavaScript with a little help from jQuery Library to post to an .aspx page. I wrote an example for PHP here http://stackoverflow.com/questions/1353678. The javascript part would stay the same, but on the server side you would have to read the query string to read in the variables using Request.querystring. Also If you want to return JSON data you will have to change the response type to be plain text rather HTML. Like this:
context.Response.ContentType = "text/plain";
Roberto Sebestyen
2009-08-31 07:34:37
the checkbox is bound to a gridview and to update the database i neeo to get the values of the other cells in the row. or the row id.. anything using rowdatabound???
2009-08-31 08:05:04
Well you are using automatically created drag and drop controls. Then for that you don't have a whole lot of control of how it functions. So your only choice is to use ASP.NET's built in AJAX framework to "ajaxify" your control. You can Google Asp.NET Ajax gridview and you will find plenty of examples. For example here is one: http://samples.gaiaware.net/Ajax-GridView.aspx
Roberto Sebestyen
2009-08-31 18:40:19
A:
use event onChange on your checkbox and make it call your ajax function..
eg with jquery:
<input type=checkbox onchange="javascript: doOnChange();">
<script>
function doOnChange() {
$.ajax({
type: "GET",
url: "/url/to/your/controller.php",
data: ...,
dataType: "html",
success: function(data){
...;
},
error: function(data){
...;
}
});
};
</script>
Abu Aqil
2009-08-31 07:36:45
the checkbox is bound to a gridview and to update the database i neeo to get the values of the other cells in the row. or the row id..
2009-08-31 08:02:12
jquery selector can help you, my suggestion is for you to learn jquery.
Abu Aqil
2009-08-31 08:20:51