Forms Data Controls :: Access BoundField Data In ItemUpdating Event Of DetailsView
Jan 2, 2010
I use ObjectDataSource and DetailsView for Updating records . my Bll input parameter method is an Object instead of regular parameter . So i though i could make my own ObjectParameter in ItemUpdating event of DetailsView and i need some modifiation on the data that user input on boudfield in detailsView . I don't know how to access BoundFiled data from ItemUpdating Method of DetailsView.
I have a detailsview that is a mix of textboxes and dropdown lists. Upon clicking update - i want to examine all of the fields that have changed and do a custom update. I am trying to capture the data using the ItemUpdating method, capturing 'e' as detailsViewUpdateEventArgs. If i specify DataKeyNames in the ASP:DetailsView and only use one key (the primarykey) then i can step through the e.oldvalues and e.newvalues examining the data - but i don't have access to the field names (except for the single key i entered).
If i use all fields from the DetailsView in the DataKeyNames parameter - then i have access to all the fieldnames via e.keys(n) - but at that point i don't have access to the e.oldvalues (count=0) I am greedy - i want the keynames, the oldvalues and the newvalues.
Can you direct me how can i access input data of DetailsView in ItemUpdating event? I want do some modification on data that user input to Detailsview.
What does work: I do see the right info if the formview is shown but when I click on the Update button it just doesnt fire the corresponding itemupdating event.
Can someone see what is wrong or missing?
What do I want to archieve: Just update the subscription's credits and its type: Upgrade, Prolong.
-edit-
New finding: I added 'onitemcommand="fvSubscriptionEdit_ItemCommand"' to the formview and a corresponding event method with a simple code that throw a exception(just testing) but it doesnt enter the method but does whine when the method is missing. So why does it whine if the method is not there but doesnt enter the method if it does exist? I presume that this is the same problem.
I have a detailsview control, which I use to enter data and save to the database. I am using object datasource to connect to the db. The detailsview control has autogenerateinsert = "true". When the insert is successfull, I want to set some variables and and to redirect the page to a different one. I don't know how to access the insert button click event of the detailsview to do it. If there is different solution like using <insertItemTemplate> and using custom linkbuttons.
I have a detailsview control which I use to enter data and save to the database. The control is connected to the db through a objectdatasource. When the insert is successful, I want to set some variables and redirect the page to a different one. The detailsview control has AutoGenerateInsertButton="True". I don't know how to access the insert button click event in the code behind,
I have a gridview with databound fields with a checkbox for each row. Only the check box is not bound to any field in the database. I have a button outside of the gridview. By clicking the button, I am trying to get the values of the partyID fields for all the rows that have the check box checked.
Upon clicking the button, nothing gets displayed but no error either.
How does one access (programatically) the data in a field in a DetailsView? The DetailsView in question has just one record but 10 fields. I assumed (wrongly?) that the DetailsView has one row, representing the record, and 10 cells, representing the fields? How does one access the fields by name?
I've tried
MyText = Dataview.Rows(0).Cells(5).Text
but I'm told that cells(5) is outside range (the field I am trying to access is the fifth field).
I have a DetailsView whose DataSource is an ObjectDataSource. The ObjectDataSource has two methods, select and update, that are stored procedures defined in a TableAdapter. The Select stored procedure takes 1 parameter--the record id--and returns the fields populated in the DetailsView. The Update stored procedure takes three parameters--the record id, and two data fields.
The select process works fine. However, when the I submit the update, I get the following error:
ObjectDataSource could not find a non-generic method Update that has parameters: [all 21 table columns]
I am trying to only pass the (3) necessary fields to the Update stored procedure, but the DetailsView is apparently trying to update using all of the fields it received from Select. I know that I can access the NewValues collection from DetailsViewUpdateEventArgs, but I don't see a way to remove any of the parameters so that they match the definition in the stored procedure, the TableAdapter, and the ObjectDataSource.
I have a DetailsView on my page, bounded throught ObjectDS (but I think it's not important). Some field is readonly for some users - based on role membership and other paramaters. I've tried to use the PreRender event to manage these field's readonly state. Everything is working - except one template field: when I click first time on Edit button the dropdown list stay readonly independently the role membership. When I click on Cancel than Edit again the control state is good. Code of PreRender event handler:
[Code]....
Environment:Web Developer 2008 Express .NET Fw. 3.5 Windows XP
The Detailsview has a template containing a textbox for one of it's fields.When an item is selected in the Gridview, I want to set a property of the textbox. How do I do that? I've tried Findcontrol for the item during Prerender of the detailsview. I've also tried many other things. Below is a portion of my aspx code followed by my VB code.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="LU_DutyStations_ID" DataSourceID="SqlDataSource1"> <Columns> asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="Duty Station Code" HeaderText="Duty Station Code" [code]...
I need to do a custom update for a form view (I think/know), as some of the parameters that are required for updating values should not be updated by the users, such as userid of the person performing the action which is passed back to the database for auditing purposes.
Additionally, there are some fields, such as LastUpdatedBy, LastUpdatedDate that need to be seen, but not edited. The stored procedure on the backend takes care of this, and these are not parameters for the Update method. The FormView by default is trying to pass all these values back to the database.
Lasty, the select query of the object datasource is a stored procedure that performs several joins based on PF/FK relationships to bring back more meaningful information than just a FK, so some columns are just the joined value, and can not be updated directly. Again, formview is trying to pass these parameters
So given that, I have defined the following even handler for a simple form view:
(not sure if this is the way to proceed given the above, but...)
2) Is so, when I cancel the edit (because I did the update myself), and change mode, the FormView returns to read only mode as inteneded (good so far). However, when I hit F5 (refresh), the ItemUpdating method is called again, and updates the database.
I have a detailsview that is listing a users membership data. userid, username etc... I have the info in template fields. Basically I have also created a button named "Delete User" at the bottom of the page outside of the detailsview. (detailsview is only displaying one user's data). When the button_click event is called I would like to delete the user using the command
[Code]....
Where username is a string I pass through from the detailsview. I am using VB and can't seem to find a way to bring the username value over from the detailsview into the button_click event.
I have used this before with no issues. Now I get to the page with the detailsview using parms I pass with the key to the row. When the page opens the row I want to update is displayed.
I am having 2 issues. One when I change any of the fields and hit Update (the Edit button),
all rows are updating not just the row displayed. The second problem is I have an update_date and an Updated_by field with code in code behind in the Onitemupdating event and they are not updating at all. (This bit of code works fine in another page I have to updated similar fields on an insert).
A DetailsView in Insert mode has all fields cleared after events such as the following:
1. Clicking New. 2. Clicking Cancel. 3. Clicking Insert (if the default mode is Insert).
I have some fields linked to ViewState and they are populatd at PreRender event handler. I am wondring if there is a single place where all relevant ViewState elements can be cleared instead of doing this in all possible relevant handlers such as ItemCreated, ItemCanceled, ItemInserted, etc.
I have GridView control and assosiated DetailView control.
When the record form GridView is seleted, I am showing the details on DetailView.
I have set the Auto generated delete button to true. And now I want to delete the record when someone clicks the Delete button from DetailView control.
I changed a text field to a template field assigning the selected text and the selected value is being assigned to another currency field also templated. I get aa error
[FormatException: Input string was not in a correct format.]