update record using ajax - asp.net

Can anyone help me regarding updating data in the gridview by using AJAX?
Once values are entered into textboxes and saved into Database, then gridview has to update the new changes. And not by using the ajax updatepanel

Why exactly are you avoiding an updatepanel? It is the simplest option.
You can use Ajax functions for several things like keyboard support or bringing a popup for data editing, but for refresh, I have found that updatepanel works the best.

Related

ASP.NET temporary disable validators

I just have started to learn ASP.NET and implementing simple application with one GridView to view and edit records, and one DetailsView to add new records.
I've added some validators for DetailsView and its works nice, but when i edit records in GridView and then try to update, those validators interfere at this moment and prevent me do update record.
What is the best practice to avoid this problem?
I tried to disable validators when i click on Grid's Update button, but it seem that validation occurs before this event.
Oh my bad, it is trivial, i found a solution at msdn tutorials:
http://msdn.microsoft.com/en-us/library/bb426882.aspx

SqlDatasource Update query controlparameter not picking the new value

if you have not encountered this problem and I have to upload my code in order to explain it for you or for you to be able to debug it, then this question is not for you.
I know I can solve this problem by using code-behind, but I don't want to do it. Eventually I will have to do it if nothing works.
I am not using any databound control (gridview,Formview,Detailview etc). Everything is a general form control: textbox and ListBox. I am using their Text and SelectedValue properties to supply values to Updatequery's ControlParameters. Everything should be working as expected. I have played with the ViewState property of the texbox control and the sqldatasource control itself, to no avail. The stored procedure used for the update command is logging the values supplied from the ASP.Net side and amazingly it shows the old values of textbox that were there when the form loads and not the changes I make.
Whats going on here?
Thanks!
Seems like you are missing something in the asp.net life cycle.
Remove any DataBind calls to your sqldatasource on page Load.
If you are using DataBind on Load to populate those text and select controls, a databind will just overwrite any values you entered.
Don't be so shy to show your code, it helps a lot in providing good answers.

GridView Sorting without losing user modifications

I have a bit of a unique problem. I am using a GridView to display information from a database. The requirements for this GridView are that it is always editable so I have TextBoxes in the ItemTemplates and want to save the values when a button is clicked.
That all works great.
The problem is I am trying to get sorting (and eventually paging) working and hitting problems. If I bind the GridView from an ObjectDataSource this obviously doesn't work because it rebinds the datasource before it sorts and I lose any modified values. If I bind the GridView from a DataTable and try to store it in a Session variable it still doesn't work because any modified values aren't in the session variable.
I'm really just looking for suggestions on what I could possibly do to sort (and page later) without losing values the user has modified. I realize most people don't modify the Gridview all at once so its a weird problem.
You could implement client-side sorting of the GridView which would have the added benefit of making your UI feel faster. There is a blog post on sorting with jQuery you could try, though I have not personally used the method suggested.
Alternatively, you could send the values back to the server via AJAX while editing and save them (temporarily) in the session, the database, or where it makes the post sense in your scenario. You would obviously need to retrieve them when sorting.
One final option would be to save your values on the postback caused by the sort command. Mostly you would do something along the lines of handling the OnTextChanged event of the TextBoxes and (as above) saving the values to a temporary store. You would not want these TextBoxes to autopostback - they would simply wait for a postback such as the one caused by your sorting event. In this scenario you could also use the temporary store you populate during the save event to avoid duplicating the effort.

How can I update a DataSource in runtime?

I have a dropdown list which retrieves data from a datasource. I must to update the dropdown when I add new data to the database through another page. I've not found documentation for this kind of updating, that would be like the requery method on DAO databases for VB6.
it really depends on how you have designed your page, you could refresh the page with a refresh button or with the refresh of the browser or even via JavaScript which reloads your page every x minutes, then you will query again everything because the page will have a full life cycle again.
if you want to do more sophisticated things you can of course use Ajax ( PageMethods or UpdatePanel approaches ) to have a partial render.
Using the databind method for the dropdown will force the update of the control. But the combo will be updated only when the page is reloaded. Maybe the best way should be using Ajax...

Create a form view, without useing the wizard

Alright so I want to create a form, where the text in the textboxs will be sent to my database, after the user hits sumbit. The problem I am facing is i am used to using a detailsview or formview to do this for me, but how can I do this myself, where I manuelly update my database.
If I understand you right, write in OnLoad event code which will generate all controls which are needed.

Resources