This code is returning me a list that I am trying to pass to another function.
_ucItem.lblItemName.Text = itemRow.Field<string>("ITEM_NAME").ToString();
_ucItem.pbxItemImg.Image = itemRow.Field<string>("IMAGE").ToString();
_ucItem.lblItemName.Text = itemRow.Field<string>("FK_ITEM_ID").ToString();
Here I want to replace this set of lines with the result set that I am trying to Pass. Do I have to declare a class for doing this or is there some way to do the same job without defining structure of a class
private void SomeFunction()
{
var distinctItems = itemListToCreate
.Select(dr => new { FK_ITEM_ID = dr.Field<long>("FK_ITEM_ID") }).Distinct()
.Join(_SelectProgram.FilteredItemDescription, outer => outer.FK_ITEM_ID,
inner => inner.Field<long>("FK_ITEM_ID"),
(inner, outer) => new
{
inner.FK_ITEM_ID,
ItemName = outer.Field<string>("ITEM_NAME"),
ItemImage = outer.Field<byte[]>("IMAGE")
}
);
CreateItemsDynamically(distinctItems.ToList());
}
private void CreateItemsDynamically<T>(List<T> itemListToCreate)
{
itemListToCreate.ForEach(itemRow =>
{
ucItem _ucItem = new ucItem();
//Compute location for this usercontrol
_ucItem.lblItemName.Text = itemRow.Field<string>("ITEM_NAME").ToString();
_ucItem.pbxItemImg.Image = itemRow.Field<string>("IMAGE").ToString();
_ucItem.lblItemName.Text = itemRow.Field<string>("FK_ITEM_ID").ToString();
_ucItem.TodayButton_OnClick += new EventHandler(_ucItem_TodayButton_OnClick);
_ucItem.MultiDateButton_OnClick += new EventHandler(_ucItem_MultiDateButton_OnClick);
pnlItemCollection.Controls.Add(_ucItem);
_SelectProgram.ItemCollectionList.Add(_ucItem);
});
}