Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > How to link dataset to a dropdownlist in bizform? View modes: 
User avatar
Member
Member
steven4733-gmail - 1/10/2012 2:22:24 PM
   
How to link dataset to a dropdownlist in bizform?
Sometimes, you want to link data from database to a dropdownlist in a bizform. I know how to do it in VS, but in Kentico is there a way that we don't have to create a custom web part?

User avatar
Member
Member
nicolas.juteau-nexun - 1/10/2012 2:31:13 PM
   
RE:How to link dataset to a dropdownlist in bizform?
Hi Steven,

Yes indeed, it is possible.

Go in the CMS Desk, edit your bizform properties. Then, in the Fields tab, select the field of type dropdownlist you want to edit, and in the section Field setting, check SQL query and put your transact-sql query there.

Regards,
Nicolas

User avatar
Member
Member
steven4733-gmail - 1/11/2012 10:09:42 AM
   
RE:How to link dataset to a dropdownlist in bizform?
Hi Nicolas,

Thank you very much for your reply. Writing SQL statement is easy, but I don't know how and where to define database connection. Could you please give me an example code?

User avatar
Member
Member
nicolas.juteau-nexun - 1/11/2012 12:34:19 PM
   
RE:How to link dataset to a dropdownlist in bizform?
Hi Steven,

I am afraid that there is no short example code I can give you to make what you want (in your case, request datas from an external database)

There are two possibilities (maybe more...) I see to make what you want:

The first is exactly what Michal (thanks for the documentation reference by the way :-) ) told in his post. Unfortunately, even though you want to avoid developing custom form controls / web parts, this is still the most straightforward way to achieve this: developing form controls. From the example described in this link, instead of adding items to the dropdownlist statically (see the method EnsureItems), you could databind your dropdownlist to a dataset which request datas from your external server (you will have to define your external database connection string in the web.config), using the standard ASP.NET ways of querying data. I don't know if it is possible using Kentico API to use another connection string...

The second, and I won't describe it in detail here as it is outside of Kentico scope, is configuring a linked server so you can use directly in Kentico a sql query using that format: SELECT * FROM ServerName.DbName.SchemaName.TableName. However, I am not 100% certain that it will work inside Kentico.

I hope it will help you.

Regards,
Nicolas

User avatar
Member
Member
kentico_michal - 1/11/2012 2:21:43 AM
   
RE:How to link dataset to a dropdownlist in bizform?
Hello,

As Nikolas has mentioned you can take advantage of the SQL query property that allows you to define a SQL query you want to execute. If you want to create some more advanced form control or execute the query using API, you can create a new form control as it is demonstrated here: Developing form controls.

Best regards,
Michal Legen