Search code examples
asp.netvisual-studio-2010.net-4.0sqldatasourcecontrolparameter

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!


Solution

  • 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.