开发者

multi column dropdownlist using C#

I want to bind data(For ex: Employee name, Employee ID from Employee) to a dropdownlist and the data should be displayed in dropdownlist as two columns. I don't want to separate this columns by using any special characters like | or '-'. I 开发者_如何学Gowant to display them as different columns in a dropdownlist.

How can i achieve this using .net and the data i need to retrieve using SQL server 2008.


Is this a WPF ComboBox? If so, use the ItemTemplate:

<ComboBox Height="23" Width="25" ItemsSource="{Binding Clients}" 
          SelectedValuePath="Client" SelectedItem="{Binding Client}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <!-- Configure as required -->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" />
                <TextBlock Text="{Binding Id}" />
             </StackPanel>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

Of course you have to format your StackPanel (or Grid, ...) to get desired output.


I used this post and basically created my own. It works pretty good except that I can't get the drop down icon to display right away. It only displays when you hover over the control. I'm sure I could do it using css and an icon, but wish it was built in.

http://www.thomasclaudiushuber.com/blog/2008/07/31/developing-multicolumn-dropdowndropdownlist-with-aspnet-the-gridview-and-the-ajax-control-toolkit/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜