|
ASP.Net DropdownList Web User Control With Customizable Indentation
I think the heading of this article explains what the project is all about.
I have created a new web user control based on DropdownList server
control. But the new control has a little twist to it. The entries in the
dropdown combobox are not displayed as flat. You can configure the combo box to
display entries with indentations. It is very much on the same lines as Master/Detail
data grid. The top level entry, Master entry, display the main category and
then indented entries, Detail data, is displayed with amount of indentation you
specify.
Input to control
You will have to provide 2 DataTable objects to the control. One
is called MasterTable and the other is called DetailTable.
You will also need to specify the names of the fields that will be used to
establish foreign key constraint between the two tables. And the last
requirement is providing the names of the fields whose values need to be shown
in the dropdown list.
What is configurable?
You can specify the following properties to customize the appearance.
-
IndentSpace: This value sets the identation space from the left of the
control
-
IndentMark: This string will be displayed in front of the detail
entries. Default value is "-". By setting an empty string you can clear the
mark.
-
MasterBackgroundColor: This value sets the background color for the
master enteries.
-
MasterForeColor: This value sets the foreground or text color for the
master entries.
-
DetailBackgroundColor: This value sets the background color for the
detail enteries.
-
DetailForeColor: This value sets the foreground or text color for the
detail entries.
How do i get the selected value?
The control appends the master and detail key field names with the values
stored in it. This appended value is set as Value of ListItem.
You can parse the values of the selected item to get the actual value stored in
it.
|