Set Selected in RadComboBox in ItemTemplate

2 posts, 0 answers
  1. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 29 Sep 2011 Link to this post

    I have a grid

    <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2007" AllowPaging="true"
                                AllowCustomPaging="true" PageSize="20" AutoGenerateColumns="False" GridLines="None"
                                AlternatingItemStyle-BackColor="#eeeeee" ShowStatusBar="true" AllowFilteringByColumn="true"
                                AllowSorting="true" EnableLinqExpressions="true" OnPreRender="RadGrid1_PreRender"
                                OnItemDataBound="RadGrid1_ItemDataBound" OnNeedDataSource="RadGrid1_NeedDataSource">
                                <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
                                <MasterTableView DataKeyNames="TaskID">
                                    <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
                                    <RowIndicatorColumn>
                                        <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>
                                    <Columns>
                                            <telerik:GridTemplateColumn SortExpression="StatusCodeTypeName"  DataField="StatusCodeTypeName"
                                            HeaderText="Status" UniqueName="StatusCodeTypeName">
                                            <ItemTemplate>
                                                <telerik:RadComboBox runat="server" ID="DropDownList1" EnableViewState="false" DataTextField="StatusCodeTypeName"
                                                    DataValueField="StatusCodeTypeID" DataSourceID="SqlDataSource1" OnClientSelectedIndexChanged="UpdateTask"
                                                    Skin="Office2007">
                                                </telerik:RadComboBox>
                                            </ItemTemplate>
                                            <FilterTemplate>
                                                <telerik:RadComboBox ID="rcbStatus" DataTextField="StatusCodeTypeName" DataValueField="StatusCodeTypeName"
                                                    AppendDataBoundItems="true" Width="150px" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("StatusCodeTypeName").CurrentFilterValue %>'
                                                    runat="server" OnClientSelectedIndexChanged="ClientNameIndexChanged" Skin="Office2007">
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
      
                                                    <script type="text/javascript">
                                                              function ClientNameIndexChanged(sender, args) {
                 
                                                                  var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                                  if (args.get_item().get_value() == "0") {
                                                                     tableView.filter("StatusCodeTypeName", args.get_item().get_value(), "NoFilter");
                                                                  }
                                                                  else {
                                                                     tableView.filter("StatusCodeTypeName", args.get_item().get_value(), "EqualTo");
                                                                  }
                                                              }
                                                    </script>
      
                                                </telerik:RadScriptBlock>
                                            </FilterTemplate>
                                            <ItemStyle VerticalAlign="Top" />
                                        </telerik:GridTemplateColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>

    In the Grid you can see it has a  GridTemplateColumn, in which is a RadComboBox for both the ItemTemplate and FilterTemplate.  The Filter template is working fine.  The porblem is in the grid it shows the item radcombobox loaded with all the selections but the current value is not the selected when in the grid.  How do I  set the selected value?

    GridTemplateColumn

  2. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 29 Sep 2011 Link to this post

    Nevermind I figured it out. 
    SelectedValue = '<%# Eval('StatusCodeTypeID') %>'
    Thought I had already included it in the code.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top