Requirements |
|
RadControls version |
2009.Q2 |
.NET version |
3.5 |
Visual Studio version |
2008 |
programming language |
C# |
browser support |
all browsers supported by RadControls |
PROJECT DESCRIPTION
@Telerik: I used the dll from RadControls_for_ASP.NET_AJAX_2009_2_701_trial_hotfix.zip - but I get no trial messages. Could you please check if the DLL is really the trial version.
Assume a (common) scenario where a column of a GridRow references a different table - the "master table" holds an ID and the related table this ID and some "Name" for it.
A typical use for a GridDropDownColumn.
But sometimes I came to a point where I couldn't use a GridDropDownColum - this happened when I had to do "very special customizations".
At this time I had to use a GridTemplateColumn. For the EditItemTemplate this is no problem - simply use a RadComboBox.
But how about the ItemTemplate?
One solution is to use a RadComboBox again - but the User should not be able to change a selection (this could confuse him).
To set the RadComboBox to Enabled="false" is also not really a solution - the thing is almost impossible to read.
Another approach is to define a datasource which allows to select the "Name" by giving an ID or to get the master data from some kind of join - which could make problems if you want to update the data.
Often I use "cached data" for things like "Country, Status, Region, Role...) - so the data is there - and I can access it very fast.
And last not least - I want to do it "the easy way" - no code behind for every grid which holds such a column.
The idea - I want to have a kind of Label which acts exactly like a ComboBox - I have a datasource(id), a selected value and so on.
As a result I get the same as with a ComboBox - but not a "unreadable" disabled thing - I just get a label (some kind of static text).
In simple words - I get the same result as with a GridDropDownColumn - but with full customization capabilities.
I built such a control (rough done -- Css class and other attributes are not rendered) and here it is.
The use is almost identical to a RadComboBox - here an example for a templated column using this control.
<telerik:GridTemplateColumn DataField="FunctionID" DataType="System.Int32" HeaderText="Function" SortExpression="FunctionID" UniqueName="FunctionID"> |
<ItemTemplate> |
<cc1:ComboLabel runat="server" DataTextField="FunctionName" DataValueField="FunctionID" DataSourceID="odsTestFunctions" SelectedValue='<%# Eval("FunctionID") %>' /> |
(<%# (string)((int)Eval("FunctionID")<2 ? "<b style='color:red;'>Handle with care</b>" : "Teasing enabled") %>) |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadComboBox ID="cbFunctionID" runat="server" DataTextField="FunctionName" DataValueField="FunctionID" DataSourceID="odsTestFunctions" SelectedValue='<%# Bind("FunctionID") %>' /> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
DataTextField, DataValueField, DataSourceID and SelectedValue
I use this control very often - and hope it is useful for you also.
To enhance the thing (more render capabilities) just change the function Render in ComboLabel (last function at the end).
Kind Regards
Manfred