







![]() ![]() |
C# Webserver |
FormHelper..::.Select Method (String, String, IEnumerable, GetIdTitle, Object, Boolean) |
FormHelper Class Example See Also Send Feedback |
Creates a select list with the values in a collection.
Namespace:
HttpServer.Helpers
Assembly:
HttpServer (in HttpServer.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C# |
---|
public static string Select( string name, string id, IEnumerable collection, GetIdTitle getIdTitle, Object selectedValue, bool firstEmpty ) |
Visual Basic (Declaration) |
---|
Public Shared Function Select ( _ name As String, _ id As String, _ collection As IEnumerable, _ getIdTitle As GetIdTitle, _ selectedValue As Object, _ firstEmpty As Boolean _ ) As String |
Visual C++ |
---|
public: static String^ Select( String^ name, String^ id, IEnumerable^ collection, GetIdTitle^ getIdTitle, Object^ selectedValue, bool firstEmpty ) |
Parameters
- name
- Type: System..::.String
Name of the SELECT-tag
- id
- Type: System..::.String
Id of the SELECT-tag
- collection
- Type: System.Collections..::.IEnumerable
collection used to generate options.
- getIdTitle
- Type: HttpServer.Helpers..::.GetIdTitle
delegate used to return id and title from objects.
- selectedValue
- Type: System..::.Object
value that should be marked as selected.
- firstEmpty
- Type: System..::.Boolean
First row should contain an empty value.
Return Value
string containtain a SELECT-tag.
Examples

// Class that is going to be used in a SELECT-tag. public class User { private readonly string _realName; private readonly int _id; public User(int id, string realName) { _id = id; _realName = realName; } public string RealName { get { return _realName; } } public int Id { get { return _id; } } } // Using an inline delegate to generate the select list public void UserInlineDelegate() { List<User> items = new List<User>(); items.Add(new User(1, "adam")); items.Add(new User(2, "bertial")); items.Add(new User(3, "david")); string htmlSelect = Select("users", "users", items, delegate(object o, out object id, out object value) { User user = (User)o; id = user.Id; value = user.RealName; }, 2, true); } // Using an method as delegate to generate the select list. public void UseExternalDelegate() { List<User> items = new List<User>(); items.Add(new User(1, "adam")); items.Add(new User(2, "bertial")); items.Add(new User(3, "david")); string htmlSelect = Select("users", "users", items, UserOptions, 1, true); } // delegate returning id and title public static void UserOptions(object o, out object id, out object title) { User user = (User)o; id = user.Id; value = user.RealName; }