Add new lookup value through webgrid column using webcombo

4 replies. Last post: March 26, 2012 9:35 PM by Yudi
Tags :
berk kurtMember

I'm trying to achieve a simple task:


For example, I have a customer data source that has the fields "Name", "Lastname" and "SchoolNameId" that schoolName is a foreign key relation to the "SchoolNames" table and I'm able to show the SchoolName.Name value from the webCombo control in the grid successfully like:


Name | Lastname | SchoolName

------------------------

Jon     | Calagham | Oxford

Carl    | Jaxs          | Stanford


All I need to achieve is to add a new SchoolName through the Customer webgrid if there's any with the one to be added.


So I've tried to set EntryMode to "InstantLookup" but since the SchoolName table needs extra columns to be set like the primary key "Id" column that are not nullable; I couldn't find a method to access the save of the lookup item.


I'd love to say thanks in advance.


Answers

Yudi Member

WebCombo supports AllowAddItem feature to allow users to add items that are not in the DataSource transparently.

When users input a text that is not in the DataSource and press Tab or lose the WebCombo’s focus, the control will invoke an OnTheFly PostBack to process OnAddItem server side event if defined. If the OnAddItem’s ReturnValue is True (default), the control will process and add the item in client side dynamically. Otherwise, it will cancel the default processing and not adding any items.

I enclosed a simple sample of this scenario as attachment. A WebGrid shows list of Products of Northwind.mdb access data base. It has ten fields: ProductID; ProductName; SupplierID; CategoryID; QuantityPerUnit; UnitPrice; UnitsInStock; UnitsOnOrder; ReorderLevel; Discontinued. WebCombo1 control is utilized as CategoryID field edit type and shows the CategoryName instead of CategoryID.

In the sample, user can type text that is not in the DataSource of Category and press Tab or lose the WebCombo’s focus, then the control will add the item in the DataSource transparently.

Please have the attached sample evaluated on your end and let us know whether this helps or not.

All Replies

Yudi Member

WebCombo supports AllowAddItem feature to allow users to add items that are not in the DataSource transparently.

When users input a text that is not in the DataSource and press Tab or lose the WebCombo’s focus, the control will invoke an OnTheFly PostBack to process OnAddItem server side event if defined. If the OnAddItem’s ReturnValue is True (default), the control will process and add the item in client side dynamically. Otherwise, it will cancel the default processing and not adding any items.

I enclosed a simple sample of this scenario as attachment. A WebGrid shows list of Products of Northwind.mdb access data base. It has ten fields: ProductID; ProductName; SupplierID; CategoryID; QuantityPerUnit; UnitPrice; UnitsInStock; UnitsOnOrder; ReorderLevel; Discontinued. WebCombo1 control is utilized as CategoryID field edit type and shows the CategoryName instead of CategoryID.

In the sample, user can type text that is not in the DataSource of Category and press Tab or lose the WebCombo’s focus, then the control will add the item in the DataSource transparently.

Please have the attached sample evaluated on your end and let us know whether this helps or not.

berk kurtMember

Thanks for the detailed answer and the sample code; I just like to ask if there's any possibility to do this using asp:linqDataSource 'cos you've given the sample with accessDataSource and I can't find the equivalent of the insertCommand etc. through the linqDataSource.


Thanks a lot

berk kurtMember

Thanks for the detailed answer and the sample code; I just like to ask if there's any possibility to do this using asp:linqDataSource 'cos you've given the sample with accessDataSource and I can't find the equivalent of the insertCommand etc. through the linqDataSource.


Thanks a lot

 

As it is understood that, linq does that automatically. Thanks for the detailed answer.

Yudi Member

Glad to hear that the sample helps.

Should you need further assistance or run into any problems regarding our controls, feel free to post it into our community site. We would be happy to assist you again.

All times are GMT -5. The time now is 8:21 AM.
Previous Next