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
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
Input to control
You will have to provide 2
DataTable objects to the control. One
is called MasterTable and the other is called
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
IndentMark: This string will be displayed in front of the detail
entries. Default value is "-". By setting an empty string you can clear the
MasterBackgroundColor: This value sets the background color for the
MasterForeColor: This value sets the foreground or text color for the
DetailBackgroundColor: This value sets the background color for the
DetailForeColor: This value sets the foreground or text color for the
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
You can parse the values of the selected item to get the actual value stored in