what is the best way of updating to db only the changed rows using gridview?
i have a gridview control that has inline editing and when the user edit the row there are two options "Update" or "Cancel" so user might just click update button without really updating the row...
how can i make sure that, user really changed the row?
I don't use it much but are you sure the GridView doesn't handle that automatically if you are using the built in edit functionality. You could try debugging the OnRowUpdated and OnRowUpdating methods to see if they even get called when save is clicked and nothing has been changed. Even if you don't need them just add them so you can put a break point there to see if they get triggered.
i could not find what i wanted to do so the easiest way of doing this is:
load the data in a object and compare with Equals it works fine in my scenario and the only cons is trip to db which is fine in my case.
Related
I'm trying to add a field from EcoResProduct to the form ReqTransPOList page but can't seem to figure it out. I've added the datasource to the query but it won't let me add any fields from it to the form. I can create a new view and adding fields to that is fine, but just can't to the form itself.
I haven't dealt much with interaction classes, am I missing something associated with this?
Thanks!
This has the easiest, yet hardest to find solution. Even though the data source was showing in the form I had to select the Data Source head and select the Query line in the properties and hit enter(you don't need to change it, just hit enter). This apparently forces a refresh that compiling, restoring, restarting AOS, and export/import couldn't do.
Please excuse me for a probably low quality of this question, since I'm not a web dev, so I possibly don't now some obvious things and don't know what to Google for. I think problem must have some simple solution, but I'm struggling with it for two days now, so I feel myself pretty stupid :-).
I have a custom control which is a set of checkboxes which are added dynamically based on a property which is set in OnLoad event of a page. I have two such controls on a page and second control items should be based on items selected in first control.
The problem is, I can't figure out, how to catch on autopostback which boxes were selected in first control before second contol is constructed to pass this data to it?
Take a look at this.
http://forums.asp.net/t/1440174.aspx
Since your building them dynamically, they are not as easy to find as webforms would like to be, if you added them to the page and wired up events and such.
Your going to look at the Request.Forms list, and search thru it for any controls you want.
I believe checkboxes are like radio buttons, they only return if they are checked, which is good, cause you want to know which ones were checked.
I've used same solution as in the accepted answer for this question: Dynamically Change User Control in ASP.Net , just need to assign an unique id for each dynamically created CheckBox in custom control. Not as clean solution as I want but at least it works.
You can save the data in the ViewState, QueryString or as Session before moving to the next page and you can do modifications based on it.
I got this error when i press a button, but i searched for that ID 'DXSelBtn0' i couldn't find it. Button is a Devexpress button, and i just add click event to it thats all. When i delete the event, i don't get that error. What should i do?
Thanks
Mehmet Şerif Tozlu
I would suggest that you create unbound columns instead as it is described in the topic available at:
http://documentation.devexpress.com/#AspNet/CustomDocument3732
If you are creating the button programatically, make sure you explicitly set the Id of the control to something unique. Or if you are in a loop, make sure you explicitly define a unique id for each control.
The DXSelBtn is a prefix used to generate IDs for select checkBoxes in the command column of the ASPxGridView. I tend to think that you are manipulating the grid in some way. Sorry, it is impossible to tell what causes this issue without your code.
I create a table in code, add rows and then cells to it. In each cell there is a checkbox which has an ID I set.
I add this table to an updatepanel, and later on I want to find out which checkboxes the user has checked/unchecked.
I don't know the best way, so what I did was create a button that checks. I kept a reference to the checkboxes, and tried changing the checkedvalue in code, but this did not update my webpage. I figure it loses the reference once it is added in code.
So I tried to use Page.FindControl and passed the original ID I gave it, but it doesn't find it. I am guessing this is because it puts a load of crap before the ID before adding it to the page...
So basically, what do I do to check the if the checkboxes I added have been altered or not? A CheckedChange event didn't work either.
You may have to use a recursive FindControl
I'm currently building a Gridview that has expandable rows. Each row contains a dynamically created Panel of Form elements. Right now, I have a javascript function that expands (or in my case, makes visible) the panel when an Image is clicked on the Gridview row.
My question is... is there a more efficient way of doing this. Instead of pulling all my data to begin with and building each new row as I Databind, is there a way to simple create the row with the Panel full of textboxes and dropdownlists on the fly when the user clicks the Expand button?"
I'd like to limit the server calls by doing it that way instead of how I'm currently doing it, looping through every row and creating a new panel with form elements and inserting that into a row that is hidden.
Actually, it isn't performing badly since my original SQL query can populate every single row and I have enabled paging on the Gridview. I'm just wondering if they can be built on the fly using PageMethods or some sort of JSON/AJAX solution. I haven't seen anything, but... worth a try in searching for it.
you can override the RowdataBound event, and than add whatever controls you want based on what data goes in the cell.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx
Personally trying to create the data on the fly would most likely result in a slower user experience.
When I do things like what you are describing I typically use Repeaters, that way I can do a template layout that simply defines all of the needed elements right away, and it handles the binding actions.
Otherwise, I would imagine that your way isn't performing too slowly as it is.
Actually worked this recently into an AJAX Handler returning the form structure. It's on demand, and works well. Simply call $ajax via jQuery, return an HTML structure, inject into DIV. It's a bit limiting on actual functionality, so be careful.