or
| <asp:DataList ID="ResultDataList" runat="server" Width="100%" > |
| <ItemTemplate> |
| <table width="100%"> |
| <tr> |
| <td> |
| <%#Eval("Question")%> |
| <asp:HiddenField ID="QuestionIDField" runat="server" Value='<%#Eval("QuestionID") %>' /> |
| </td> |
| </tr> |
| <tr> |
| <td > |
| <telerik:RadChart ID="RadChart1" runat="server" Width="500" Height="250" ChartTitle-Visible="false" CreateImageMap="false" DataGroupColumn="ColumnText"> |
| <PlotArea> |
| <XAxis DataLabelsColumn="OptionText"> |
| </XAxis> |
| </PlotArea> |
| </telerik:RadChart> |
| </td> |
| </tr> |
| <tr><td><hr /></td></tr> |
| </table> |
| </ItemTemplate> |
| </asp:DataList> |
| <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SurveyDBConnectionString %>" |
| SelectCommand="select optiontext,text,isnull((select COUNT(resultid) from SurveyResult where OptionID=SurveyOption.OptionID and ColumnID=ColumnOption.ColumnOptionID group by OptionID ),'0') as RespondentCount from SurveyOption,ColumnOption where SurveyOption.QuestionID=ColumnOption.QuestionID and SurveyOption.QuestionID= @QID"> |
| <SelectParameters> |
| <asp:Parameter Name="QID" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| Protected Sub ResultDataList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles ResultDataList.ItemDataBound |
| If (Not e Is Nothing) Then |
| Dim chart As RadChart = CType(e.Item.FindControl("RadChart1"), RadChart) |
| Dim h As HiddenField = CType(e.Item.FindControl("QuestionIDField"), HiddenField) |
| SqlDataSource2.SelectParameters(0).DefaultValue = h.Value |
| chart.DataSource = SqlDataSource2.Select(DataSourceSelectArguments.Empty) |
| chart.Legend.Appearance.GroupNameFormat = "ColumnText" |
| chart.DataBind() |
| End If |
| End Sub |
I have a normal RadGrid and in that grid columns like this:
| <telerik:GridTemplateColumn |
| HeaderText="MyColumn" |
| UniqueName="MyColumn"> |
| <ItemTemplate> |
| <asp:Label ID="MyColumnLabel" runat="server" Text='<%# Eval("MyColumn") %>'></asp:Label> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <telerik:RadComboBox |
| ID="Domains" |
| DataTextField="MyColumn" |
| DataValueField="MyColumnID" |
| Runat="server"> |
| </telerik:RadComboBox> |
| </EditItemTemplate> |
| </telerik:GridTemplateColumn> |
Then in the code-behind:
| protected void MyGrid_OnItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditableItem) && e.Item.IsInEditMode) |
| { |
| GridEditableItem gridEditableItem = (GridEditableItem)e.Item; |
| RadComboBox myComboBox = (RadComboBox)gridEditableItem.FindControl("MyComboBox"); |
| this.businessData = new BusinessData(); |
| // Don't worry about this. It pulls data from the business layer and databinds the ComboBox. |
| TelerikHelper.BindRadComboBox(myComboBox, businessdataData.Select(), false); |
| } |
| } |
Everything works fine as is. In non-edit view, the correct value is displayed and in edit view, the combobox is displayed, populated with values.
But I also want to set the selected item in the databound dropdown to the text value set in MyColumnLabel.
I must be having an off-day because I simply cannot work out how to do it :(
Can anyone enlighten me? I've been through any number of examples on the Telerik site with no luck.
Regards,
Richard