DataSource Controls :: DetailsView Get Key After Insert

Sep 11, 2010

I'm trying to catch (in string "s") the primary key for the record being inserted via DetailsView. I have an SqlDataSource connection to an Access 2003 database. The primary key is auto-increment integer (long) field.

[Code]....

generates an error: System.Data.OleDb.OleDbDataAdapter internal error: invalid parameter accessor: 12 BADBINDINFO.

View 2 Replies


Similar Messages:

DataSource Controls :: Sql Insert Failing On Detailsview Insert Or Update?

Mar 6, 2010

I am using 1 textbox with a Ajax Calendar extender to allow my user's to select a date graphically (exp: 12/15/2009). I have another textbox for the hour and minutes in military time(exp: 15:30). I think i have the code to grab the data from the 2 textbox's and combine them to be inserted into the field (exp: 12/15/2009 15:30). Here is my insert code for the Field:

[Code]....

However unless I make all the fields Nullable the insert fails, on top of that none of the other field that I have selected on the Detailsview Insert or Edit are inserted into there fields. Half of my fields have to be non-null values. So how do I fix this?

I can supply additional vb code and the aspx code if needed.

This is the error I'm getting: Cannot insert the value NULL into column 'Operation_type', table '/GAOSDB.MDF.dbo.BC_Perf_Log'; column does not allow nulls. INSERT fails. The statement has been terminated.'

This is the first non-null column.

I need to get this figured out because I have 30 other web pages that will be utilizing the same approach.

View 4 Replies

DataSource Controls :: Insert A Foreign Key Into Detailsview?

Jan 28, 2010

I am trying to insert a foreign key into detailsview so that user didn't have to enter value every time. I am using the following code to do this but it is failing. I am not sure what needs to be done now.

Protected Sub LinqDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceInsertEventArgs) Handles LinqDataSource1.Inserting
LinqDataSource1.InsertParameters("Company").DefaultValue = Session("Company_new").ToString()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim company As String = Request.QueryString("Company")
Session("Company_new") = company
End Sub
End Class

View 2 Replies

DataSource Controls :: DetailsView Update And Insert Buttons Do Nothing

Jan 14, 2011

Not sure where I went wrong with this one, but I can't figure it out now... I've got a DetailsView in an UpdatePanel. A dropdownlist controls which person's details are displayed in the DetailsView. I have the DataSource set to an ObjectDataSource, which has select, insert and update methods defined. I also have a method for the ItemCommand, ItemInserting, ItemUpdating and DataBound events of the DetailsView specified.

When I click "New" or "Edit" on the DetailsView I get the open form with either the details for the current person, or a blank form, exactly as I would expect. But when I click the "Update" or "Insert" buttons it does absolutely nothing. I have it running in debug, and have put breakpoints in the ItemCommand, ItemInserting and ItemUpdating methods, right at the top, and it never goes there. The form remains open, and nothing happens. If I click "Cancel", it posts back and goes back to ReadOnly mode.

A couple more minor details that may be important: This page is using a Master page, which is where the ScriptManager is. I'm actually using the ScriptManager from the AjaxControlToolkit. I also have a GridView in this same UpdatePanel, and that has a FileUpload control in it. Because the FileUpload control doesn't work properly without some tweaking, I have to call a RegsiterPostbackTrigger method on page load to link it back to the Master page's scriptmanager. Not sure if that's causing any issues...?

I had this working fine, but then as the page got more complex and I had to change some of the code, at some point it just stopped working and now I can't figure out how to get this working again... I'm happy to post code if necessary, just thought I'd try this first to see if anyone has a quick idea for what to check.

View 13 Replies

AJAX :: Refreshing DDL In Detailsview After Insert New Record In DDL Datasource

Aug 5, 2010

I have a scenario in which the user can add a new option to appear in the list of available choices in a DDL contained in a detailsview when they select an option <Add New>. This displays an AJAX model popup which then allows the user to enter the new option text. Then they hit an Insert button which inserts that new option into the DDL's datasource and I call ddl.DataBind. Subsequently I want to close the modal popup and then display the newly created DDL option as selected.

When I step through the code, everything appears to be working as expected...i.e. the DDL's datasource now has 1 more record than before and the ddl.SelectedValue is the newly created record for its datasource. I can also query ddl.items(99) and see the new option is part of the ddl's items collection and the new record is Selected.

HOWEVER, once the screen comes back from the debugger, the DDL is now showing the newly created option, but still the prior selected option of "<Add New>". And if you pull the DDL down the newly created option is not in the list?

I cannot figure out how that happens...though I suspect it has something to do with the AJAX/Update panel. Here's some code:

[Code]....

[Code]....

[Code]....

[Code]....

[Code]....

[Code]....

View 1 Replies

Forms Data Controls :: DetailsView EmptyDataTemplate After Insert Defaults To Empty Insert Screen

Jan 27, 2010

In my detailsview, I have an emptydatatemplate set up to allow users to enter new records. The code works. However, once the record is inserted, the detailsview defaults to a standard insert screen. I know this will cause confusion for the users. I would prefer the detailsview to either show in edit mode or a read-only mode. I have used detailsview.changemode and detailsview.currentmode in the custom sub created for the add new button of the emptydatatemplate- neither of which do what I was hoping. It would be even better if when there was no data, it defaulted to the insert screen (which seems like that should be an easy, no-brainer way for .net to function) but it doesn't. Or, I don't know how to accomplish it.

I don't want to force the user to click cancel after inserting an item through the emptydatatemplate just to be able to use the detailsview for other records.

View 2 Replies

Forms Data Controls :: Insert DetailsView Dont Show Read-only Data After Insert?

May 7, 2010

I have a problem with DetailsView linked with Database, DetailsView is Insert/Edit enabled, and adding/ediditng data works, however........ when I add a new record (DetailsView in Insert mode) and press INSET instead going to record I have just created in Read-Only Mode it shows me blank form, it looks that the "linking" field is null.

View 3 Replies

Access :: Insert Not Working - Adding Additional Parameters To Insert From DetailsView

Jul 13, 2010

Getting the message that ObjectDataSource ... count not find a non-generic method ... that has parameters ... The parameter list is fine until I get to the very end and it list the two data fields that are in my DetailsView. Using the ASP Tutorial #17 (Examining the Events Associated with Inserting, Updating, and Deleting) and the Exploring the Data Modification - specifically the one showing the INSERT of the Product Name and UnitPrice. ASPX page is pretty simple and attempting something similar, two fields to insert a new record - update the other fields later.

Full Error Message follows along with ASPX and the AsignaturasBLL.cs. Interesting thing is that when I swap the two fields in the DetailView, then the last two fields in the error message are swapped. In the error message I bolded these two fields.

[Code]....

View 6 Replies

Forms Data Controls :: DetailsView - Go To New Record After Insert?

Apr 18, 2010

Is it possible to code DetailsView to go to the new record I've just insertted? Currently it appears to default to the first record, utlimatly I'd like it sorted Last name, first name and upon an Insert it should go to that new record on pageload.

View 3 Replies

Forms Data Controls :: DetailsView - INSERT Default Value

Mar 23, 2010

I am using DetailsView to INSERT new records. I have a field "Paid Date"(date) that needs to be pre-populated with the current date. 90% of the time, the user will use the default date, however, there are times when the user will need to change the data as needed. I want to add this default in the code-behind. I DO NOT want to use template item.

View 3 Replies

Forms Data Controls :: Insert A New File Using DetailsView?

Mar 13, 2010

1- THE METHOD :

public static int Insertclient(
int Cod_client,
string Nom,
string Tel,
string Adresse)

[Code]....

2- InsertClient.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Collections;

[Code]....

3- Database:

4- clientDetailsView :

5 - My request :

When cod_client already exisits , i want to mention that in result message.

View 6 Replies

Forms Data Controls :: Can't Insert From A Dropdownlist Within A Detailsview?

Oct 18, 2010

I figure that this should be relatively straightforward, but I still can't get it to work. I have a gridview and a detailsview to set up shifts for students and teachers. I would like to be able to insert new shifts using a detailsview. I will limit the students, teachers and location to items that are in a dropdownlist. The problem is that when I handle the iteminserting event. the e.values collection doesn't contain all of the fields I want to populate. How do I add the new fields to the list. This is my codebehind:

Sub On_Inserting(ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs)

View 3 Replies

Forms Data Controls :: Cannot Insert Value Of Bound Dropdownlist In Detailsview

Apr 25, 2010

I have a dropdownlist in the edititemtemplate of a detailsview. The dropdownlist is bound with an objectdatasource. The detailsview is bound to a seperate objectdatasource which connects it to the insert method. When the page loads the dropdownlist is bound properly. However, when I make a selection and select insert I get the following error: Could not find a property named 'DeptID' on the type specified by the DataObjectTypeName property in ObjectDataSource 'objCurrentProduct'. I've tried to remove the SelectedValue='<%# Bind("DeptID") %> attribute. I can then insert without an exception being thrown but the selected value of the dropdown is not recognized. Here is the code:

[Code]....

[Code]....

View 2 Replies

Forms Data Controls :: Insert Record In Nested Detailsview?

Oct 30, 2010

Scenario : I have two database tables with one to many relationship. eg:- City and Related news. So I have a gridview(Gridview1) which lists out all the cities and allows edit, delete of the gridview rows. Now since i wanted to display all news for the city, i have a nested gridview as a column in this Gridview1. This nested gridview displays all the news for the cities. And I have edit, delete buttons for this gridview too - So far, good - works fine.

Now what I would like to do is - To insert a new news item for a city. For this, I attached a detailsview to my nested grid(gridview2), and tried to insert. I need the primary key id of city table from the first grid (gridview1) to insert the news into the second database table and I could not access this value from the parent gridview. My gridview1 does not have datakeyname, it is programatically bound.

Also, When the gridview/detailsview is nested, it does not get listed in the event-handler list. So I cannot use say, detailsview1_iteminserting. I do not how to add this event handler

Has anybody done anything similar? When I started, it looked like a pretty straightforward thing - There must be some way to do this. But I just can't get it to work. How do you usually insert into the child table in a one-to-many relationship? Should i just be using two separate gridviews?

View 5 Replies

Forms Data Controls :: Validating Insert Values In Detailsview?

Oct 26, 2010

I'm inserting data into a SQL database through a detailsview. When a user inserts an incorrect data type or leaves a required field blank it shoots off to a big error screen. Is there a control that I can use that will allow it to give an error (with a little star or something) that says which field is incorrect without the big error screen?

View 3 Replies

Forms Data Controls :: Insert Control Into Detailsview Row At Run Time?

Dec 24, 2010

'' I try to add an TemplateField to my DetailsView control with calander control, in all modes. but can only add it to cell(0).how can i insert in the middle of the row?

Dim tmpfld As New TemplateField
Dim c As Calendar = New Calendar()
DetailsView1.Rows(0).Cells(4).Controls.Add(c)

View 4 Replies

Forms Data Controls :: Detailsview In Insert Mode With Objectdatasource

Aug 25, 2010

i have a detailsview in insert mode and that is bound to objectdatasource. now the class that is attached to objectdatasource is :

[Code]....

here ResturantId value has to be in session or from Dropdownlist and rest of the value from Detailview. So how to assign that value?

View 3 Replies

Forms Data Controls :: Set Default Value In Detailsview Insert Mode

Nov 17, 2010

How do I set the value of a field in a detailsview to the selectedvalue of a gridview on the same page? I am also trying to set today date as value of another field in the detailsview as well as UserID. I wrote the following codebehind for the date setting:

TextBox tb = (TextBox)DetailsView2.FindControl("TextBoxCreDate");
tb.Text=System.DateTime.Now.ToShortDateString();
TextBoxCreDate is a template field in my DetailsView.

Unfortunately, I get a Object reference not set to an instance of an object. Error message.

View 4 Replies

Forms Data Controls :: Change Nulls To 0 On Detailsview Insert?

Nov 19, 2010

I'm looking to find some command or control that will change fields in a detailsview insert a 0 if there was no data inserted into them. Some example code from my boundfield is:

<asp:BoundField DataField="Assignment_Travel_Time"

View 3 Replies

Forms Data Controls :: Insert Command Not Using Selected Value From DDL In A DetailsView?

Oct 8, 2010

My web form contains a detailsview control that I have added a templated field to with a DropDownList in the InsertItemTemplate. The DetailsView default mode is 'insert. My detailsview is attached to a sqldatasource that has a stored procedure in the db to handle the insert. When I enter data in the fields and select insert all values from the detailsview are written to the table except for the selection that was made in the dropdownlist. I am using the ddl.selecteditem.value to populate my variable however when the insert method is envoked it doesn't send my value. The DDL value that I am capturing does not need to be written to the table it is just a flag for some variables that need to be set at the stored proc level. How do I get the DDL selected value to be sent with the insert statement?

Here is my code behind:

Protected
Sub
DropDownList1_SelectedIndexChanged(ByVal sender
As
Object,
ByVal e
As System.EventArgs)
Dim temp
As DropDownList
Dim AccessLevel
As
String
temp = AddUserDetailsView.FindControl("DropDownList1")End
Sub
AccessLevel = temp.SelectedItem.Value
Label1.Text = AccessLevel

View 2 Replies

DataSource Controls :: Pass In As An Insert Parameter For SQLds2 The Scope_identity Of The Insert Of SQLds1

Jan 12, 2010

I am trying to pass in as an insert parameter for SQLds2 the scope_identity of the insert of SQLds1.

Exception Details: System.InvalidOperationException: Error executing 'InsertCommand' in SqlDataSource 'SqlDataSource1'. Ensure the command accepts the following parameters: @Name1, @NewId

[Code]....

View 4 Replies

DataSource Controls :: Insert In To 2 Tables Using A SQL And Details View Insert Functionality?

Aug 12, 2010

I do have a details view, which insert data to a database table using SQL Datasource. Now i need the data to be inserted in to 2 tables instead of one.

View 1 Replies

Forms Data Controls :: Detailsview Disapears When Clicking Insert Button?

Feb 1, 2010

I have got a detailsview in my webpage that inserts an item into a database when I click the insert button.

Once this button is clicked, the detailsview dissapears. Why it does this I don't know.

Some of my code:

[Code]....

View 3 Replies

Forms Data Controls :: DetailsView - Set Textbox Text When Going To Insert Mode?

Jan 19, 2011

I guess I'm not sure exactly how or where to do what I need.

First off - here's what I need - - when the user clicks on the NEW button in the detailsView, I have the User.Identity.name captured in a variable and I need to set one of the textboxes (InsertItemTemplate) named 'txtNew' to that name.

I've tried using the ModeChanging (and ModeChanged) event:
Dim
dv As
TextBox =
CType(DetailsView1.FindControl("txtNew"),
TextBox)
If (e.NewMode =
DetailsViewMode.Insert)
Then ....

However, no matter what, 'dv' always shows as 'Nothing', so I can't change the text of it.

Where do I put the logic and what am I missing?

View 2 Replies

Forms Data Controls :: GridView Paging After - Insert Record From DetailsView

Jun 23, 2010

GirdView and DetailsView in defautl.aspx. When i insert a new record using detailsview it works and gridview is updated. But i want jump to the right page in gridview after importing the record. How can i highlight the new row imported record in Girdview. I use ajax so gridview and detailsview are in updatepanel.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved