This is a migrated thread and some comments may be shown as answers.

ItemDataBound event in Multicolumn dropdown

1 Answer 77 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Neema Sridhar
Top achievements
Rank 1
Neema Sridhar asked on 13 Jul 2010, 07:22 AM

Hi,

 


I am implementing a multicolumn radcombo and I need to access indiviual column values. I saw from the demo that this can be acheived by setting attributes. and this I am trying to do in ItemDataBound event. But in ItemDatabound event e.Item.DataItem is null, Please have a look at the below code and let me know what could be the issue. The data is getting beinded to the drodown, but datatitem is null

ASPX CODe

 

<telerik:RadComboBox ID="RadComboBox1" runat="server" Width="150px"  HighlightTemplatedItems="true" CssClass="cmb_borderstyle"
                                        OnClientSelectedIndexChanged="onClientSelectedIndexChanged" 
                                        DropDownWidth="200px" EnableEmbeddedSkins="false" Skin="NextGen" CausesValidation="false" OnItemDataBound="RadComboBox1_ItemDataBound">
                                            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                            <ItemTemplate>                                            
                                            <div class="cmb_ltFlt" style="width:100%">
                                                <div class="cmb_rdFnt cmb_ltFlt">
                                                    <%# DataBinder.Eval(Container.DataItem, "paymentTypeDesc") %>Item1</div>
                                                <div class="cmb_rdFnt cmb_ltFlt cmb_sp20">
                                                    <%# DataBinder.Eval(Container.DataItem, "delvOptionDesc")%>Row1 Col2</div>
                                                <div class="cmb_rdFnt cmb_ltFlt cmb_sp20">
                                                    <%# DataBinder.Eval(Container.DataItem, "serviceFQN") %>Row1 Col3</div>                                            
                                                </div>
                                                  
                                            </ItemTemplate>
                                        </telerik:RadComboBox>


C# Code

public class PaymentSelectionData 
    
        public string paymentTypeDesc { get; set; } 
        public string delvOptionDesc { get; set; } 
        public string serviceFQN { get; set; } 
        public string refVal { get; set; } 
    }
//Below logic is implemented in some method and called form PageLoad 
List<PaymentSelectionData> lstPmtSel = new List<PaymentSelectionData>(); 
    
for (int i = 1; i <= 5; i++) 
                    
                        pmtSelData = new PaymentSelectionData(); 
                        pmtSelData.paymentTypeDesc = "PaymentTypeDesc" + i.ToString(); 
                        pmtSelData.delvOptionDesc = "DelvOption" + i.ToString(); 
                        pmtSelData.serviceFQN = "ServiceFQN" + i.ToString(); 
                        pmtSelData.refVal = pmtSelData.paymentTypeDesc + "#" + pmtSelData.delvOptionDesc + "#" + pmtSelData.serviceFQN; 
                        lstPmtSel.Add(pmtSelData); 
    
    
RadComboBox1.DataValueField = pmtSelData.refVal; 
                    RadComboBox1.DataTextField = "paymentTypeDesc"
    
                    RadComboBox1.DataSource = lstPmtSel; 
                    RadComboBox1.DataBind(); 
    
protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e) 
        
            //row is null
            System.Data.DataRowView row = e.Item.DataItem as System.Data.DataRowView; 
}

 

 

public

 

class PaymentSelectionData

 

 

 

 

 

{

 

public string paymentTypeDesc { get; set; }

 

 

public string delvOptionDesc { get; set; }

 

 

public string serviceFQN { get; set; }

 

 

public string refVal { get; set; }

 

}

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 13 Jul 2010, 09:50 AM
Hello Neema Sridhar,

The DataItem you are getting with the 'as' operator is null because the underlying type of the DataItem is PaymentSelectionData, i.e. it is not DataRowView. If you change the type then the code should work properly.

Greetings,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Neema Sridhar
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or