Folks,
I am using VS2010 with RadControls for ASP.NET AJAX Q2 2012 SP1. I would like to hide certain ComboBox items based on Values from an array. Below is my complete code. Any help will be appreciated.
Thanks
gc_0620
________________
I am using VS2010 with RadControls for ASP.NET AJAX Q2 2012 SP1. I would like to hide certain ComboBox items based on Values from an array. Below is my complete code. Any help will be appreciated.
Thanks
gc_0620
________________
<
telerik:RadComboBox
ID
=
"Address_LocationRadComboBox"
runat
=
"server"
SelectedValue='<%# Bind("Address_Location") %>'
Text='<%# Bind("Address_Location") %>' Width="150px">
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"Florida"
Value
=
"Florida"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"New Jersey"
Value
=
"New Jersey"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"New York"
Value
=
"New York"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"Ohio"
Value
=
"Ohio"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"Wisconsin"
Value
=
"Wisconsin"
/>
</
Items
>
</
telerik:RadComboBox
>
.........
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
string[] retrievedLocations = (string[])Session["LocationData"];
Array.Sort(retrievedLocations);
// Assuming Array retrievedLocations has following Values:
// New Jersey
// New York
// Wisconsin
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
// Beginning of Loop each row in array retrievedLocations until no rows in array
RadComboBox combo = (RadComboBox)item.FindControl("Address_LocationRadComboBox");
foreach (RadComboBoxItem ComboItem in combo.Items)
{
if (ComboItem.Value != row value of array retrievedLocations)
{
ComboItem.Visible = false;
}
else
{
ComboItem.Visible = true;
}
}
// End of Loop each row in array retrievedLocations until no rows in array
}
}