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

ComboBox Custom Attribute Value

1 Answer 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff Wickersham
Top achievements
Rank 1
Jeff Wickersham asked on 24 Apr 2013, 06:14 PM
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;
        }
        
    }

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 29 Apr 2013, 02:18 PM
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.
Tags
ComboBox
Asked by
Jeff Wickersham
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or