Hello,
I am binding to an arraylist which contains object items with properties 'name' and 'val', when I call DataBind, ComboBo items are successfully created, but I'am unable to select one of the items.
It's so trivial that I'm thinking I have an error somewhere else, here is my code:
It runs in the Page_Load event of my page, not other interaction after.
The radCombo is not ajaxified, no autopostback.
| ArrayList ar = im.CategoryList; |
| RadComboCat.DataSource = ar; |
| RadComboCat.DataValueField = "val"; |
| RadComboCat.DataTextField = "name"; |
| RadComboCat.DataBind(); |
| if ( catId == 0 ) |
| { |
| RadComboCat.SelectedIndex = 0; |
| } |
| else |
| { |
| string strCat = catId.ToString(); |
| Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatComboSelected FindItemByValue: [{0}], catId:{1}",strCat,catId),CrmImageTrace.Sw.Info); |
| RadComboBoxItem it = RadComboCat.Items.FindItemByValue(strCat); |
| Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatComboSelected FindItemByValue found : {0}", it != null ),CrmImageTrace.Sw.Info); |
| if (it != null) |
| { |
| it.Selected = true; |
| Trace2.WriteLine( string.Format("[V]CRMImageEdit FillCatCombo Selected Item: {0}, catId:{1}",it.Text,catId),CrmImageTrace.Sw.Info); |
| } |
| } |
Trace shows that the it.Selected= true instruction is executed, but when page is displayed, nothing is selected.
When I select from the UI, the value is well selected and I can store it ????
What could be the reason ?
(Hollidays I know....)
Thanks
CS

| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridTest.aspx.cs" Inherits="<...our path here...>Presentation.Web.UI.InventoryManagement.gridTest" %> |
| <%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <title>Untitled Page</title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <rad:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" |
| AutoGenerateColumns="False" |
| EnableAJAX="True" GridLines="None" Skin="Outlook2007"> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| <MasterTableView DataKeyNames="StaustOutcomeId" CommandItemDisplay="Bottom" EditMode="InPlace" > |
| <Columns> |
| <rad:GridButtonColumn CommandName="Edit" UniqueName="Edit" Text="Edit" ButtonType="ImageButton" |
| HeaderText="Edit"> |
| </rad:GridButtonColumn> |
| <rad:GridBoundColumn DataField="Outcome" HeaderText="Outcome" SortExpression="Outcome" |
| UniqueName="Outcome"> |
| </rad:GridBoundColumn> |
| <rad:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status" |
| UniqueName="Status"> |
| </rad:GridBoundColumn> |
| <rad:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" |
| UniqueName="Description"> |
| </rad:GridBoundColumn> |
| <rad:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean" HeaderText="IsActive" |
| SortExpression="IsActive" UniqueName="IsActive"> |
| </rad:GridCheckBoxColumn> |
| <rad:GridBoundColumn DataField="SalesChannel" HeaderText="SalesChannel" SortExpression="SalesChannel" |
| UniqueName="SalesChannel"> |
| </rad:GridBoundColumn> |
| <rad:GridBoundColumn DataField="StaustOutcomeId" DataType="System.Int32" HeaderText="StaustOutcomeId" |
| ReadOnly="True" SortExpression="StaustOutcomeId" UniqueName="StaustOutcomeId"> |
| </rad:GridBoundColumn> |
| </Columns> |
| <ExpandCollapseColumn Resizable="False" Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| </rad:RadGrid> |
| </div> |
| </form> |
| </body> |
| </html> |
| using System; |
| using System.Data; |
| using System.Configuration; |
| using System.Collections; |
| using System.Web; |
| using System.Web.Security; |
| using System.Web.UI; |
| using System.Web.UI.WebControls; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Web.UI.HtmlControls; |
| using System.Collections.Generic; |
| namespace <...our path here...>.Presentation.Web.UI.InventoryManagement |
| { |
| public partial class gridTest : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| List<StatusOtcm> lst = new List<StatusOtcm>(3); |
| for (int i=0; i<3; i++) |
| lst.Add(new StatusOtcm()); |
| RadGrid1.DataSource = lst; |
| RadGrid1.DataBind(); |
| } |
| } |
| class StatusOtcm |
| { |
| public string Description |
| { |
| get { return "some Description"; } |
| } |
| public string Outcome |
| { |
| get { return "OC"; } |
| } |
| public string Status |
| { |
| get { return "Complete"; } |
| } |
| public bool IsActive |
| { |
| get { return true; } |
| } |
| public string SalesChannel |
| { |
| get { return "P"; } |
| } |
| public int StaustOutcomeId |
| { |
| get { return 25;} |
| } |
| } |
| } |
<
telerik:RadTabStrip ID="testTS" runat="server" Skin="Office2007">
<Tabs>
<telerik:RadTab runat="server" ID="tab1" Text="tab 1" />
</Tabs>
</telerik:RadTabStrip>
...
var
testTS = $find( "<%=testTS.ClientID %>" );
Thank you.
<
MasterTableView Width="100%" DataKeyNames="TeamKey">
<DetailTables>
<telerik:GridTableView Width="100%" runat="server" Name="AssignedCoaches" DataKeyNames="TeamToCoachKey">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="TeamKey" MasterKeyField="TeamKey" />
</ParentTableRelation>
<Columns>
<telerik:GridBoundColumn DataField="CoachAndType"/>
<telerik:GridTemplateColumn HeaderText="Remove" ItemStyle-HorizontalAlign=center>
<ItemTemplate>
<asp:ImageButton CommandName="DeleteRecord" TabIndex=-1 id="ibDelete" imageUrl="../images/delete.png" CausesValidation="False" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="TeamToCoachKey" Visible="false"/>
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn HeaderText="Team and # of Coaches" DataField="TeamAndCount" UniqueName="TeamToCoachKey"/>
<telerik:GridBoundColumn DataField="TeamKey" Visible="false"/>
</Columns>
</MasterTableView>