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
Related
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.
I have a aspxgridview with details row.
in detils row of this gridview, there are about 10 aspxgridviews. whenever one of this grids cause callback by clicking edit/new/delete , other gridview also databound i.e hit database. this cause performance issue.
Is there a way to disable databinding on other aspxgridview?
tanks.
You can use tab content lazy loading. Look here for example and here for further explanation.
i find a solution here:
ASPxPageControl - Page Load of all TabPages
I have an ASP.NET page with a Wizard control containing several steps and about 80 form fields. The data is collected and inserted to a database from the code behind page. I need to set this form up so you can not only insert, but edit a record as well. So I want to databind the fields. I'd rather not use a FormView because then I would have to revise my existing code, since you can't access controls inside a FormView directly. Is there a way to databind the fields without using a FormView? I'm new at this by the way so sorry if the answer should be obvious.
A wizard is just a UI control with many steps in it. You can use it to insert, edit, delete or anything else you can think of. You can have an INSERT wizard and an EDIT wizard. The difference would be that there would be two of them and that the code behind for each one (presumably on the CompletedStep) would have slightly different code to persist the data. The insert wizard would call an insert database query and the edit one would call an update query.
That being said, you can access the control inside a FormView, I'm not sure why you said that you can't access controls indie a FormView. You can. See Using FindControl: Accessing Controls in a Formview.
You could even put the two wizards inside the two states of the formview - InsertTemplate and EditTemplate but thats getting a little crazy :)
I have a web page with a datagrid and a user control.
The user control has an event which the web page subscribes to.
On the user control event I need to rebind the datagrid on the web page.
I'm coming up with all sorts of problems due to extender controls that are attached to the grid indicating that they cannot be registered after prerender so it looks like the user control event occurs to late in the page life cycle. Either way those kinda errors would indicate that I'm on the wrong track completely.
I do not want a reference to my page in the user control if at all possible.
What is the best way to achieve this.
I had tried Binding the grid on PageLoad every time but found that although the Databind happened and the updated data was in the datasource that the grid contents did not reflect this. [Is it the GridView viewstate thats playing with this?]
Ding a full refresh or using a button to the page to rebind the grid allowed me to display the correct value.
Thanks in advance,
Liam
"I had tried Binding the grid on PageLoad every time but found that
although the Databind happened and the updated data was in the
datasource that the grid contents did not reflect this. [Is it the
GridView viewstate thats playing with this?]".
I think that the answer (in part at least) to this is that the third party control is using callbacks to get back to the server and not postbacks so this may be the issue. As I understand it the grid was binded OK but not rendered. [I hadn't come across the differences between Callbacks and Postbacks until this week!!]
I'm open to correction on this though. :)
Liam
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.