I want to bind the RADGrid with ObjectDatasource. One of the properties of the object is a BusinessAreaKey. Hence my object only have Key (e.g 'FIN' for fianancial Services). I have to show the user 'Financial Services' as buiness area instead of key 'FIN'. I have stored all the business Areas in xml file as Key-value pairs. So I read the xml data in objectDataSource as BusinessAreas.
I am using GridDropdownColumn to show the business areas. In RADGrid1_ItemDatabound() event, I am binding the column with the list of available business Areas with the check that item is an EditItem.
Problem that I am facing is: When RADGrid is initially loaded, I don't see the data in BunessAreas column. But when I click to update any row, business areas in all the rows below shows me correct values as expected.
protected
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
BLL.DealflowCompany dfCompany = null;
string idString ="";
if (e.Item.ItemType== GridItemType.EditItem)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
GridDropDownListColumnEditor editor =
editMan.GetColumnEditor("BusinessAreaKey") as GridDropDownListColumnEditor;
try{// Exception for new Item
idString = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString();
if (!string.IsNullOrEmpty(idString))
{
dfCompany = BLL.DealflowCompany.FromID(Convert.ToInt32(idString));
editor.DropDownListControl.SelectedValue = dfCompany.BusinessAreaKey;
}
}
catch{}
if(editor!=null)
{
editor.DataSource = LBOffice.Website.Language.GetBusinessAreas(Session["language_path"].ToString());
editor.DataTextField="Area";
editor.DataValueField = "Key";
editor.DataBind();
if(dfCompany!=null)
editor.SelectedValue = dfCompany.BusinessAreaKey;
}
}
I will appreciate if you can help me in resolving this issue.
Thanks.