ComboBox Custom Attribute Value

2 posts, 0 answers
  1. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 24 Apr 2013 Link to this post

    Having an issue using the custom attribute, i need the value to use for my combo selected index changed
    ddlDealer_SelectedIndexChanged

    here is my combo markup
                        <ul>
                                <li class="col4">
                                       <%# DataBinder.Eval(Container.DataItem, "DepartmentId") %>
                                     </li>            
                                </ul>
    protected void ddlDealer_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            DataRowView dataRowSource = (DataRowView) e.Item.DataItem;
            e.Item.Text = ((DataRowView)e.Item.DataItem)["Dealer"].ToString();
            e.Item.Value = ((DataRowView)e.Item.DataItem)["DealerId"].ToString();
            e.Item.Attributes["DepartmentId"] = dataRowSource["DepartmentId"].ToString();
        }

      protected void ddlDealer_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            try
            {
                int departmentId = Convert.ToInt32(ddlDealer.SelectedItem.Attributes["DepartmentId"]);
                LoadCategoryList(departmentId);
            }
            catch (Exception)
            {
                
                throw;
            }
            
        }
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 29 Apr 2013 Link to this post

    Hi Jeff,

    Your code looks fine and this is the correct way to retrieve custom attribute's value. I have created a small samples based on the provided information. However I was not able to reproduce the same behavior as you. For your reference I'm attaching my sample. Please check it out and let me know if I have missed something.

    Thanks.

    Regards,
    Hristo Valyavicharski
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top